-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cakefile
63 lines (50 loc) · 1.41 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
fs = require "fs"
{print} = require "util"
{spawn} = require "child_process"
glob = require "glob"
_ = require 'lodash'
DOCKER = "fuzzyio/hostnamer"
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) ->
print data.toString()
proc.on "exit", (code) ->
callback?() if code is 0
build = (callback) ->
cmd "coffee -c -o lib src", callback
buildDocker = (callback) ->
cmd "docker build -t #{DOCKER} .", callback
buildTest = (callback) ->
cmd "coffee -c test", callback
task "build", "Build lib/ from src/", ->
build()
task "build-test", "Build for testing", ->
invoke "clean"
invoke "build"
buildTest()
task "clean", "Clean up extra files", ->
patterns = ["lib/*.js", "test/*.js", "*~", "lib/*~", "src/*~", "test/*~"]
for pattern in patterns
glob pattern, (err, files) ->
for file in files
fs.unlinkSync file
task "test", "Test the auth", ->
invoke "clean"
invoke "build"
buildTest ->
cmd "./node_modules/.bin/vows --spec -i test/*-test.js"
task "docker", "Build docker image", ->
invoke "clean"
build ->
buildDocker()
task "push", "Push docker image", ->
cmd "docker push #{DOCKER}"