diff options
author | Guillermo Iguaran <guilleiguaran@gmail.com> | 2017-03-13 10:11:14 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-13 10:11:14 -0500 |
commit | a5746cb4ecc524f465ff305d1ff5d5b85c05fd53 (patch) | |
tree | 494aed46dc62201c7e09c9b285ad5a2526bf43ee /actioncable/Rakefile | |
parent | 5a053052ad882ffe73394727e911a5fa7d18884c (diff) | |
parent | 2d2b3025ec6f2b68f0cea524ee97322b6e349e6c (diff) | |
download | rails-a5746cb4ecc524f465ff305d1ff5d5b85c05fd53.tar.gz rails-a5746cb4ecc524f465ff305d1ff5d5b85c05fd53.tar.bz2 rails-a5746cb4ecc524f465ff305d1ff5d5b85c05fd53.zip |
Merge pull request #28385 from javan/actioncable/fix-npm-package
Restore action_cable.js UMD module support. Fixes #28366
Diffstat (limited to 'actioncable/Rakefile')
-rw-r--r-- | actioncable/Rakefile | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/actioncable/Rakefile b/actioncable/Rakefile index 87d443919c..bda8c7b6c8 100644 --- a/actioncable/Rakefile +++ b/actioncable/Rakefile @@ -1,12 +1,13 @@ require "rake/testtask" require "pathname" +require "open3" require "action_cable" dir = File.dirname(__FILE__) task default: :test -task package: "assets:compile" +task package: %w( assets:compile assets:verify ) Rake::TestTask.new do |t| t.libs << "test" @@ -37,6 +38,39 @@ namespace :assets do desc "Compile Action Cable 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/action_cable.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 " + stdout, stderr, status = Open3.capture3("node", "--print", "window = {}; require('#{dir}');") + if status.success? + puts "[OK]" + else + $stderr.puts "[FAIL]\n#{stderr}" + fail + end + end end |