forked from github/game-off-2012
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathCakefile
41 lines (34 loc) · 1017 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
32
33
34
35
36
37
38
39
40
41
fs = require 'fs'
path = require 'path'
{exec} = require 'child_process'
source_dir = 'src'
target_dir = 'js'
target_name = 'zoko'
required_order = [
source_dir + '/Observable.coffee'
]
task 'build', 'build js file', ->
command = 'coffee -c -b -o ' + target_dir + ' -j ' + target_name + '.coffee'
# Files required to be in a specific order comes first
for file in required_order
command += ' ' + file
# Then the rest of the files
files = readdir source_dir, '.coffee'
for file in files
if required_order.indexOf(file) is -1
command += ' ' + file
exec command, ( err, stdout, stderr ) ->
throw err if err
console.log 'Done!'
# Recursive, synchronous readdir
readdir = ( dir, ext ) ->
filelist = []
files = fs.readdirSync dir
for file in files
file = dir + '/' + file
stats = fs.statSync file
if stats.isDirectory()
filelist = filelist.concat readdir file, ext
else if path.extname( file ) is ext
filelist.push file
return filelist