forked from josephg/ShareJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cakefile
56 lines (42 loc) · 1.5 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
{exec} = require 'child_process'
closure = require './thirdparty/closure'
fs = require 'fs'
task 'test', 'Run all tests', ->
require './tests'
task 'build', 'Build the .js files', (options) ->
exec "coffee --compile --bare --output lib/ src/", (err, stdout, stderr) ->
throw err if err
console.log stdout + stderr
client = [
'client/web-prelude'
'client/microevent'
'types/helpers'
'types/text'
'client/client'
]
# Backticks
e = (str, callback) ->
console.log str
exec str, (err, stdout, stderr) ->
throw err if err
out = stdout + stderr
console.log out if out != ''
callback() if callback?
compile = (infile, outfile) ->
# Closure compile the JS
file = fs.readFileSync infile
closure.compile file, (err, code) ->
throw err if err?
smaller = Math.round((1 - (code.length / file.length)) * 100)
output = outfile
fs.writeFileSync output, code
console.log "Closure compiled: #{smaller}% smaller (#{code.length} bytes} written to #{output}"
task 'webclient', 'Build the web client into one file', ->
clientfiles = ("src/#{c}.coffee" for c in client).join ' '
# I would really rather do this in pure JS.
e "coffee -j webclient/share.uncompressed.js -c #{clientfiles}", ->
console.log "Building with closure's REST API..."
compile 'webclient/share.uncompressed.js', 'webclient/share.js'
# TODO: This should also be closure compiled.
exec "coffee --compile --output webclient/ src/client/ace.coffee", (err, stdout, stderr) ->
e "mv webclient/ace.js webclient/share-ace.js"