-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cakefile
49 lines (41 loc) · 1.63 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
{exec} = require 'child_process'
findExecutable = (executable, callback) ->
exec "test `which #{executable}` || echo 'Missing #{executable}'", (err, stdout, stderr) ->
throw new Error(err) if err
callback() if callback
build = (callback) ->
exec 'mkdir -p lib', (err, stdout, stderr) ->
throw new Error(err) if err
exec "coffee --compile --output lib/ lib/", (err, stdout, stderr) ->
throw new Error(err) if err
callback() if callback
exec "browserify --standalone Timetress --ignore jquery ./lib/timetress.js > ./lib/standalone.js"
removeJS = (callback) ->
exec 'rm -fr lib/', (err, stdout, stderr) ->
throw new Error(err) if err
callback() if callback
checkDependencies = (callback) ->
findExecutable 'coffee', ->
findExecutable 'mocha', (err, stdout) ->
(callback or console.log) (stdout)
test = (callback = console.log) ->
checkDependencies ->
build ->
exec "./node_modules/.bin/mocha \
--reporter spec --require should --compilers coffee:coffee-script/register --colors", (err, stdout) ->
callback(err) if err
callback(stdout) if stdout
publish = (callback = console.log) ->
build ->
findExecutable 'npm', ->
exec 'npm publish', (err, stdout) ->
callback(stdout)
dev_install = (callback = console.log) ->
build ->
findExecutable 'npm', ->
exec 'npm link .', (err, stdout) ->
callback(stdout)
task 'build', 'Build lib from coffeescript source', -> build()
task 'test', 'Test project', -> test()
task 'publish', 'Publish project to npm', -> publish()
task 'dev-install', 'Install developer dependencies', -> dev_install()