-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathRakefile
47 lines (41 loc) · 1.37 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
require 'fileutils'
require 'bundler'
Bundler.require
desc 'compile code (creates palava.js and palava.min.js)'
task :compile do
sprockets = Sprockets::Environment.new(File.dirname(__FILE__)) { |env|
# env.logger = Logger.new(STDOUT)
env.append_path 'coffee'
}
# palava.js
asset = sprockets['main.coffee']
asset.write_to('palava.js')
puts Paint["Successfully built palava.js", :green]
# palava.min.js
uglifier_options = JSON(File.read(File.dirname(__FILE__) + '/uglifier_options.json'))
File.open('palava.min.js', 'w'){ |f|
f.write Uglifier.compile File.read('palava.js'), uglifier_options
}
puts Paint["Successfully built palava.min.js", :green]
end
desc 'generate bundle file, which contains all dependencies (creates palava.min.js)'
task bundle: [:compile] do
# palava.bundle.js
sh 'npm install'
FileUtils.rm 'palava.bundle.js'
%w[
node_modules/webrtc-adapter/out/adapter_no_edge.js
node_modules/wolfy87-eventemitter/EventEmitter.min.js
palava.min.js
].each{ |input_file|
File.open('palava.bundle.js', 'a'){ |f| f.puts File.read(input_file) }
}
FileUtils.rm_r 'node_modules'
puts Paint["Successfully built palava.bundle.js", :green]
end
desc 'generate codo documentation'
task :docs do
sh 'codo -n "palava-client" -t "palava-client documentation" -o docs'
end
desc 'create bundle and docs'
task prepare_release: [:bundle, :docs]