-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cakefile
40 lines (33 loc) · 957 Bytes
/
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
fs = require 'fs'
{print} = require 'util'
{spawn, exec} = require 'child_process'
pkg_files = [
'lib'
'images'
'vendor'
'manifest.json'
'README.md'
'LICENSE'
].join ' '
version = ->
JSON.parse(fs.readFileSync('manifest.json')).version
zip_out = ->
"pkg/always_inject_jquery-#{version()}.zip"
build = (watch=false) ->
options = ['-w', '-c', '-o', 'lib', 'src']
options.shift '-w' unless watch
coffee = spawn 'coffee', options
coffee.stderr.on 'data', (data) ->
process.stderr.write data.toString()
coffee.stdout.on 'data', (data) ->
print data.toString()
zip = ->
try fs.mkdirSync 'pkg', 0o0755
exec "zip -r #{zip_out()} #{pkg_files}"
task 'build', 'build all CoffeeScript in src to JavaScript in lib', ->
build()
task 'watch', 'watch for changes to CoffeeScript in src and build to JavaScript in lib', ->
build true
task 'zip', "build an upload-ready Chrome extension to #{zip_out()}", ->
build()
zip()