-
Notifications
You must be signed in to change notification settings - Fork 21
/
Cakefile
63 lines (48 loc) · 1.77 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
{print} = require 'util'
{spawn} = require 'child_process'
task 'build', 'Build lib/ from src/', ->
# Get parameters from package.json
pkg = require('./package.json')
# Specify the name of the library
output = "lib/#{pkg['name']}.js"
# Check that developer has specified a dependency order
unless pkg['_dependencyOrder']?
process.stderr.write "ERROR: The dependency order must be specified in package.json\n"
return
# Concatentate the dependency order
order = pkg['_dependencyOrder']
for dep, index in order
order[index] = "src/#{dep}.coffee"
# Set the flags for coffeescript compilation
flags = ['-j', output, '-c'].concat order
# Compile to JavaScript
coffee = spawn 'coffee', flags
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
task 'watch', 'Build lib/ from src/', ->
# Get parameters from package.json
pkg = require('./package.json')
# Specify the name of the library
output = "lib/#{pkg['name']}.js"
# Check that developer has specified a dependency order
unless pkg['_dependencyOrder']?
process.stderr.write "ERROR: The dependency order must be specified in package.json\n"
return
# Concatentate the dependency order
order = pkg['_dependencyOrder']
for dep, index in order
order[index] = "src/#{dep}.coffee"
# Set the flags for coffeescript compilation
flags = ['-w', '-j', output, '-c'].concat order
# Compile to JavaScript
coffee = spawn 'coffee', flags
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