-
Notifications
You must be signed in to change notification settings - Fork 82
/
Rakefile
54 lines (43 loc) · 1.43 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
require 'json'
LIBRARY = [ "api.js", "feed.js", "lib.js", "cli.js" ]
BROWSER_TOOLS = Dir.glob("browser/*").select{|x| x != "browser/export.js" }
task :default => :export
desc 'Export Follow for use in web browsers'
task :export => ([:clean, "cli.js"] + LIBRARY + BROWSER_TOOLS) do |task|
build = "./build"
target = "#{build}/follow"
sh "mkdir", "-p", target
LIBRARY.each do |js|
sh "node", "browser/export.js", js, "#{target}/#{js}"
end
BROWSER_TOOLS.each do |file|
sh "cp", file, build
end
# EventEmitter2 needs wrapping.
sh "node", "browser/export.js", "browser/eventemitter2.js", "#{build}/eventemitter2.js"
File.open("#{build}/boot.js", 'w') do |boot|
requirejs_paths = { 'request' => 'request.jquery',
'events' => 'eventemitter2',
# 'foo' => 'bar', etc.
}
opts = { # 'baseUrl' => "follow",
'paths' => requirejs_paths,
}
main_js = "main.js"
boot.write([ 'require(',
'// Options',
opts.to_json() + ',',
'',
'// Modules',
[main_js].to_json() + ',',
'',
'// Code to run when ready',
'function(main) { return main(); }',
');'
].join("\n"));
end
end
desc 'Clean up build files'
task :clean do
sh "rm", "-rf", "./build"
end