aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/Rakefile
diff options
context:
space:
mode:
authorJavan Makhmali <javan@javan.us>2017-03-30 14:40:39 -0400
committerJavan Makhmali <javan@javan.us>2017-03-30 14:40:39 -0400
commite0ac3498c669fad7aab18436fc84f9e52b72bc8a (patch)
tree33f09c3a29c93f4cdf6b4ac3b24c1054d85dece9 /actionview/Rakefile
parent93982de132f5e3fdcd7794d697a6566bd98da393 (diff)
downloadrails-e0ac3498c669fad7aab18436fc84f9e52b72bc8a.tar.gz
rails-e0ac3498c669fad7aab18436fc84f9e52b72bc8a.tar.bz2
rails-e0ac3498c669fad7aab18436fc84f9e52b72bc8a.zip
Restore rails-ujs.js UMD module support
Diffstat (limited to 'actionview/Rakefile')
-rw-r--r--actionview/Rakefile43
1 files changed, 42 insertions, 1 deletions
diff --git a/actionview/Rakefile b/actionview/Rakefile
index 00ab92129d..4adcc723b1 100644
--- a/actionview/Rakefile
+++ b/actionview/Rakefile
@@ -1,10 +1,13 @@
require "rake/testtask"
require "fileutils"
+require "open3"
+
+dir = File.dirname(__FILE__)
desc "Default Task"
task default: :test
-task package: "assets:compile"
+task package: %w( assets:compile assets:verify )
# Run the unit tests
@@ -84,8 +87,46 @@ namespace :assets do
desc "Compile Action View assets"
task :compile do
require "blade"
+ require "sprockets"
+ require "sprockets/export"
Blade.build
end
+
+ desc "Verify compiled Action Cable assets"
+ task :verify do
+ file = "lib/assets/compiled/rails-ujs.js"
+ pathname = Pathname.new("#{dir}/#{file}")
+
+ print "[verify] #{file} exists "
+ if pathname.exist?
+ puts "[OK]"
+ else
+ $stderr.puts "[FAIL]"
+ fail
+ end
+
+ print "[verify] #{file} is a UMD module "
+ if pathname.read =~ /module\.exports.*define\.amd/m
+ puts "[OK]"
+ else
+ $stderr.puts "[FAIL]"
+ fail
+ end
+
+ print "[verify] #{dir} can be required as a module "
+ js = <<-JS
+ window = { Event: class {} }
+ class Element {}
+ require('#{dir}')
+ JS
+ stdout, stderr, status = Open3.capture3("node", "--print", js)
+ if status.success?
+ puts "[OK]"
+ else
+ $stderr.puts "[FAIL]\n#{stderr}"
+ fail
+ end
+ end
end
task :lines do