-
Notifications
You must be signed in to change notification settings - Fork 1
/
Cakefile
60 lines (46 loc) · 1.8 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
fs = require 'fs'
{print} = require 'util'
{spawn} = require 'child_process'
{_} = require 'underscore'
if process.platform is 'win32'
# 'C:/Users/Norbert/AppData/Roaming/npm/coffee.cmd'
regex = /\\/g # to fix syntax highlighting issue in sublime
BINPATH = (process.env.APPDATA.replace regex, '/')+"/npm/"
EXTENSION = '.cmd'
else
BINPATH = EXTENSION = ''
COFFEE = BINPATH + 'coffee' + EXTENSION
HANDLEBARS = BINPATH + 'handlebars' + EXTENSION
CODO = BINPATH + 'codo' + EXTENSION
spawner = (cmd, opts, callback) ->
coffee = spawn cmd, opts
coffee.stderr.on 'data', (data) ->
process.stderr.write data.toString()
coffee.stdout.on 'data', (data) ->
print data.toString()
coffee.on 'exit', (code) ->
callback?() if code is 0
spawnCoffee = (opts, callback) ->
spawner(COFFEE, opts, callback)
spawnHandlebars = (opts, callback) ->
spawner(HANDLEBARS, opts, callback)
spawnCodo = (opts, callback) ->
spawner(CODO, opts, callback)
task 'build', 'Build build/ from src/', ->
spawnCoffee ['-c', '-o', 'build/server', 'src/server']
spawnCoffee ['-c', '-o', 'build/client', 'src/client']
spawnCoffee ['-c', '-o', 'build/tests', 'tests']
task 'watch', 'Build build/ from src/', ->
spawnCoffee ['-w', '-c', '-o', 'build/server', 'src/server']
spawnCoffee ['-w', '-c', '-o', 'build/client', 'src/client']
spawnCoffee ['-w', '-c', '-o', 'build/tests', 'tests']
task 'precompile', 'Precompile handlebars templates', ->
spawnHandlebars ['templates', '-f', 'build/client/templates.js']
task 'doc', 'Compile docs', ->
walk = require('walkdir')
files = walk.sync('src/client')
files = _.filter files, (file) -> /\.coffee$/.test(file)
files = _.sortBy files, (file) ->
parts = file.split('/')
parts[parts.length - 1]
spawnCodo ['--readme', 'README.md', '-o', 'doc'].concat(files)