-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
65 lines (55 loc) · 1.31 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
require "rake/testtask"
require "bundler/gem_tasks"
require "open3"
task default: :test
task test: ["test:helpers", "test:assets", "test:javascripts"]
namespace :test do
Rake::TestTask.new(:helpers) do |t|
t.pattern = "test/helpers/*test.rb"
end
task assets: ["assets:compile", "assets:verify"]
task :javascripts do
abort unless system "bin/blade ci"
end
end
namespace :assets do
desc "Compile assets"
task :compile do
require "blade"
require "sprockets"
require "sprockets/export"
Blade.build
end
desc "Verify compiled assets"
task :verify do
file = "app/assets/javascripts/local-time.js"
pathname = Pathname.new("#{__dir__}/#{file}")
print "[verify] #{file} exists "
if pathname.exist?
puts "[OK]"
else
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 = {}
document = { documentElement: {} }
require("#{__dir__}")
JS
_, stderr, status = Open3.capture3("node", "--print", js)
if status.success?
puts "[OK]"
else
puts "[FAIL]\n#{stderr}"
fail
end
end
end