-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathRakefile
More file actions
72 lines (57 loc) · 1.42 KB
/
Rakefile
File metadata and controls
72 lines (57 loc) · 1.42 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
67
68
69
70
71
72
require 'fileutils'
include FileUtils
ROOT = __dir__.freeze
BIN = "#{ROOT}/node_modules/.bin".freeze
def cmd_exists?(cmd)
File.exists?(cmd) && File.executable?(cmd)
end
def ensure_cmd(cmd)
$cmd_cache ||= []
return true if $cmd_cache.include? cmd
paths = ENV['PATH'].split(':').uniq
unless paths.any?{|p| cmd_exists? "#{p}/#{cmd}" }
raise "'#{cmd}' command doesn't exist"
else
$cmd_cache << cmd
end
end
file 'bower_components' do
ensure_cmd 'bower'
sh 'bower install'
end
file 'node_modules' do
ensure_cmd 'npm'
sh 'npm install'
end
file "typings" do
ensure_cmd 'tsd'
sh 'tsd install'
end
task :dep => %i(node_modules bower_components typings)
task :build_browser_src => %i(typings) do
sh "#{BIN}/tsc -p #{ROOT}/browser"
end
task :build_renderer_src do
mkdir_p 'build/renderer'
ts_tmp_dir = "#{ROOT}/renderer-ts-compiled"
sh "#{BIN}/tsc -p #{ROOT}/renderer"
sh "#{BIN}/browserify -d -o #{ROOT}/build/renderer/index.js #{ts_tmp_dir}/index.js"
end
task :build => %i(dep build_browser_src build_renderer_src)
task :run do
sh "#{ROOT}/bin/cli.js"
end
task :all => %i(build run)
task :asar do
mkdir 'archive'
begin
%w(bower.json package.json index.html style build resource).each{|p| cp_r p, 'archive' }
cd 'archive' do
sh 'npm install --production'
sh 'bower install --production'
end
sh "#{BIN}/asar pack archive app.asar"
ensure
rm_rf 'archive'
end
end