-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCakefile
44 lines (35 loc) · 1.21 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
fs = require 'fs'
path = require 'path'
{exec} = require 'child_process'
base = path.basename
report = (err) -> puts err if err
builder = (dir, fn) ->
fs.readdir "src/#{dir}/", (err, files) ->
report err
fn file for file in files
watcher = (dir, fn) ->
fs.readdir "src/#{dir}/", (err, files) ->
report err
for file in files
fs.watchFile "src/#{dir}/#{file}", (curr, prev) ->
fn file unless curr.mtime.toString() is prev.mtime.toString()
jade = (file) ->
lib = "#{base file, '.jade'}.html"
exec "jade src/pages/#{file} -p > lib/#{lib}", execer file, lib
sass = (file) ->
lib = "#{base file, '.sass'}.css"
exec "sass src/styles/#{file}:lib/css/#{lib}", execer file, lib
coffee = (file) ->
lib = "#{base file, '.coffee'}.js"
exec "coffee -p src/scripts/#{file} > lib/js/#{lib}", execer file, lib
execer = (file, lib) -> (err) ->
report err
puts "Wrote #{file} to #{lib}." unless err
task 'build', 'Builds the source code into the lib directory.', ->
builder 'pages', jade
builder 'styles', sass
builder 'scripts', coffee
task 'watch', 'Watches for changes on all files and builds when appropriate.', ->
watcher 'pages', jade
watcher 'styles', sass
watcher 'scripts', coffee