-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCakeFile
More file actions
65 lines (50 loc) · 1.52 KB
/
CakeFile
File metadata and controls
65 lines (50 loc) · 1.52 KB
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
64
65
### Build file for CoffeePhysics. ###
fs = require 'fs'
uglify = require 'uglify-js'
{exec, spawn} = require 'child_process'
config =
compiled: 'js'
deploy: 'deploy'
source: 'src'
test: 'tests'
spec: 'tests/specs'
output =
'phallanxpress': [
'base'
'cache'
'phallanxpress'
'models/base_model'
'models/tag_model'
'models/category_model'
'models/post_model'
'models/page_model'
'models/author_model'
'collections/base_collection'
'collections/categories_collection'
'collections/pages_collection'
'collections/posts_collection'
'collections/tags_collection'
'collections/authors_collection'
]
task 'watch', 'Watch & compile changes in source dir', ->
watch = exec "coffee -o #{config.compiled}/ -cw #{config.source}/"
watch.stdout.on 'data', (data) ->
process.stdout.write data
task 'test', 'Watch and compile changes in src dir and test dir', ->
watch = exec "coffee -o #{config.test}/js/ -cw #{config.spec}/"
watch.stdout.on 'data', (data) ->
process.stdout.write data
task 'build', '', ->
for target, files of output
mapped = files.map (file) ->
file = "#{config.source}/#{file}.coffee"
file = "#{config.deploy}/#{target}.js"
toExec = "coffee -j #{file} -c #{(mapped.join ' ')}"
exec toExec
console.log toExec
fs.readFile file, 'utf8', (err, data) ->
ast = uglify.parser.parse data
ast = uglify.uglify.ast_mangle ast
ast = uglify.uglify.ast_squeeze ast
code = uglify.uglify.gen_code ast
fs.writeFile "#{config.deploy}/#{target}.min.js", code