-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
66 lines (54 loc) · 1.5 KB
/
Rakefile
File metadata and controls
66 lines (54 loc) · 1.5 KB
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
66
ROOT = File.dirname __FILE__
task :default => :build
desc "Run automated tests."
task :test => ['node_modules', :build] do
sh "bin/runtests"
end
build_deps = [
'dist',
'dist/node_modules',
'dist/capsulate.js',
'dist/package.json',
'dist/README.md',
'dist/MIT-LICENSE'
]
desc "Build JavaScript files."
task :build => build_deps do
puts "build done ..."
end
desc "Install development dependencies."
file 'node_modules' => 'package.json' do
# sh "npm install --dev" Results in infinte loop
sh "sudo npm install"
end
directory 'dist'
file 'dist/node_modules' => 'dist/package.json' do
Dir.chdir 'dist'
sh "npm install --production"
Dir.chdir ROOT
end
file 'dist/package.json' => ['package.json', 'dist'] do |task|
FileUtils.cp task.prerequisites.first, task.name
end
file 'dist/README.md' => ['README.md', 'dist'] do |task|
FileUtils.cp task.prerequisites.first, task.name
end
file 'dist/MIT-LICENSE' => ['MIT-LICENSE', 'dist'] do |task|
FileUtils.cp task.prerequisites.first, task.name
end
file 'dist/capsulate.js' => ['capsulate.coffee', 'dist'] do |task|
brew_javascript(task.prerequisites.first, task.name)
end
desc "Start over with a clean slate."
task :clean do
rm_rf 'node_modules'
rm_rf 'dist'
end
def brew_javascript(source, target, node_exec=false)
File.open(target, 'w') do |fd|
if node_exec
fd << "#!/usr/bin/env node\n\n"
end
fd << %x[node_modules/coffee-script/bin/coffee -pb #{source}]
end
end