-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCakefile
78 lines (69 loc) · 2.32 KB
/
Cakefile
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
73
74
75
76
77
fs = require 'fs'
{print} = require 'util'
{spawn, exec} = require 'child_process'
option "-b", '--browserified [BROWSERIED]', 'which file should be browserified'
try
which = require('which').sync
catch err
if process.platform.match(/^win/)?
console.log 'WARNING: the which module is required for windows\ntry: npm install which'
which = null
# ## *launch*
#
# **given** string as a cmd
# **and** optional array and option flags
# **and** optional callback
# **then** spawn cmd with options
# **and** pipe to process stdout and stderr respectively
# **and** on child process exit emit callback if set and status is 0
launch = (cmd, options=[], callback) ->
cmd = which(cmd) if which
app = spawn cmd, options
app.stdout.pipe(process.stdout)
app.stderr.pipe(process.stderr)
app.on 'exit', (status) ->
if status is 0
callback() if callback
else
process.exit(status);
task "compileclient", "Compile coffee files in /client directiory", (options)->
options = ['-c', '-o', 'public/js/', 'client/']
launch 'coffee', options
task "browserify", "Browserify special js files", (options)->
switch options.browserified
when 'background'
source = 'public/js/extension/background/background.js'
target = 'extensions/chrome/js/background.js'
break
when 'popup'
source = 'public/js/extension/popup/popup.js'
target = 'extensions/chrome/js/popup.js'
break
when 'contentScript'
source = 'public/js/extension/contentScripts/initExtension.js'
target = 'extensions/chrome/js/todoExtension.js'
break
when 'cabinet'
source = 'public/js/site/cabinet/init.js'
target = 'public/js/site/cabinet.js'
break
when 'frontpage'
source = 'public/js/site/frontpage/init.js'
target = 'public/js/site/frontpage.js'
break
else
throw new Error('Try browserify invalid configured file')
options = [source, '-o', target]
launch 'browserify', options
task "packeverything", "Compily and Browserify all files", (options)->
invoke 'compileclient'
options.browserified = 'background'
invoke 'browserify'
options.browserified = 'popup'
invoke 'browserify'
options.browserified = 'contentScript'
invoke 'browserify'
options.browserified = 'cabinet'
invoke 'browserify'
options.browserified = 'frontpage'
invoke 'browserify'