-
Notifications
You must be signed in to change notification settings - Fork 2
/
Rakefile
61 lines (48 loc) · 1.23 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
55
56
57
58
59
60
61
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 'node_modules' do
ensure_cmd 'npm'
sh 'npm install'
end
file 'typings' do
ensure_cmd 'tsd'
sh 'tsd install'
end
# %i() is unavailable because of version of Ruby on Travis
task :dep => [:node_modules, :typings]
task :build_browser_src => [:typings] do
sh "#{BIN}/tsc -p #{ROOT}/browser"
end
task :build_renderer_src => [:typings] do
mkdir_p "#{ROOT}/build/renderer"
sh "#{BIN}/tsc -p #{ROOT}/renderer"
sh "#{BIN}/browserify -d #{ROOT}/renderer/out/main.js -o #{ROOT}/build/renderer/index.js"
end
task :build => [:dep, :build_browser_src, :build_renderer_src]
task :run do
sh "#{ROOT}/bin/cli.js"
end
task :default => [:build, :run]
task :lint do
Dir['browser/**/*.ts'].each do |f|
sh "tslint #{f}"
end
Dir['renderer/**/*.ts', 'renderer/**/*.tsx'].each do |f|
sh "tslint #{f}"
end
end