forked from antoniogarrote/NodeJS-WebID-demo
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCakefile
36 lines (33 loc) · 1.07 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
fs = require 'fs'
{exec} = require 'child_process'
javascripts = {
'webid' : [
'WebID',
'VerificationAgent',
'Foaf'
]
}
task 'build', 'Build applications described in javascripts var', ->
try
fs.mkdirSync 'bin'
catch err
#do nothing
for javascript, sources of javascripts
appContents = new Array
console.log 'Processing ' + javascript
for source, index in sources then do (source, index) ->
console.log ' `- ' + source
appContents[index] = fs.readFileSync "src/#{source}.coffee", 'utf8'
file = 'bin/' + javascript + '.coffee'
console.log 'writing coffee file:' + file
fs.writeFileSync file, appContents.join('\n\n'), 'utf8', (err) ->
throw err if err
console.log 'Compiling ' + javascript
compileAndDelete javascript
compileAndDelete = (javascript) ->
exec 'coffee --output bin/ --compile bin/' + javascript + '.coffee ', (err, stdout, stderr) ->
console.log stdout + stderr
throw err if err
fs.unlink 'bin/' + javascript + '.coffee', (err) ->
throw err if err
console.log 'Done.'