forked from emberjs-addons/ember-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Assetfile
54 lines (45 loc) · 1.21 KB
/
Assetfile
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
LICENSE = File.read("generators/license.js")
class RegisterWrapper < Filter
def generate_output(inputs, output)
inputs.each do |input|
id = input.path.sub('/lib/','/').sub(/\.js$/, '')
code = "\nminispade.register('#{id}', function(exports) {\n#{input.read}\n});\n"
output.write code
end
end
end
class RequireRewrite < Filter
def generate_output(inputs, output)
inputs.each do |input|
result = input.read
result.gsub!(%r{^\s*require\(['"]([^'"]*)['"]\);?\s*}) do |s|
module_id = $1
module_id.sub!(/^\./, File.dirname(input.path))
module_id << '/main' if module_id !~ /\//
module_id.sub!('~tests','tests')
"minispade.require('#{module_id}');"
end
output.write result
end
end
end
input "packages"
output "tests/source"
match "*/{lib,tests}/**/*.js" do
filter RegisterWrapper
filter RequireRewrite
filter ConcatFilter do |filename|
filename =~ %r{/tests/} ? "ember-tests.js" : "ember.js"
end
end
# Hack to ignore certain files
match "**/*.{json,md}" do
filter ConcatFilter, "trash"
end
match "**/README" do
filter ConcatFilter, "trash"
end
match "*/*.js" do
filter ConcatFilter, "trash"
end
# vim: filetype=ruby