-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCakefile
74 lines (58 loc) · 1.57 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
fs = require "fs"
{spawn} = require "child_process"
glob = require "glob"
_ = require "lodash"
DOCKERIMAGE = "fuzzyio/personalhunt"
cmd = (str, env, callback) ->
if _.isFunction(env)
callback = env
env = null
env = _.defaults(env, process.env)
parts = str.split(" ")
main = parts[0]
rest = parts.slice(1)
proc = spawn main, rest, {env: env}
proc.stderr.on "data", (data) ->
process.stderr.write data.toString()
proc.stdout.on "data", (data) ->
process.stdout.write data.toString()
proc.on "exit", (code) ->
callback?() if code is 0
build = (callback) ->
cmd "coffee -c -o lib src", callback
buildTest = (callback) ->
cmd "coffee -c test", callback
buildDocker = (callback) ->
cmd "sudo docker build -t #{DOCKERIMAGE} .", callback
push = (callback) ->
cmd "sudo docker push #{DOCKERIMAGE}", callback
clean = (callback) ->
patterns = ["lib/*.js", "test/*.js", "*~", "lib/*~", "src/*~", "test/*~"]
for pattern in patterns
glob pattern, (err, files) ->
for file in files
fs.unlinkSync file
if callback?
callback()
task "clean", "Clean up extra files", ->
clean()
task "build", "Build lib/ from src/", ->
clean ->
build()
task "buildtest", "Build test", ->
clean ->
build ->
buildTest()
task "test", "Test the API", ->
clean ->
build ->
buildTest ->
cmd "vows --spec test/*-test.js"
task "docker", "Build docker image", ->
clean ->
build ->
buildDocker()
task "push", "Deploy to repository", ->
push()
task "run", "Run the server", ->
cmd "sudo docker-compose up"