-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCakefile
31 lines (25 loc) · 970 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
{spawn, exec} = require "child_process"
spawnChild = (command, options, callback) ->
child = spawn command, options
console.log "spawned child for '" + command + "'. pid: " + child.pid
child.stdout.on "data", (data) -> process.stdout.write data.toString()
child.stderr.on "data", (data) -> process.stderr.write data.toString()
process.on "SIGHUP", () -> child.kill()
process.on "SIGINT", () -> child.kill()
child.on "exit", (status) -> callback?(status)
return child
build = (watch, callback) ->
if typeof watch is "function"
callback = watch
watch = false
options = ["-c", "-o", "build/", "source/"]
if watch
options.unshift "-w"
spawnChild "coffee", options, callback
task "build", "Compile CoffeeScript source files", () ->
build()
task "watch", "Recompile CoffeeScript source files when modified", () ->
build true
task "start", "Start server", () ->
build false, (status) ->
if status is 0 then spawnChild "node", ["build/server.js"]