-
Notifications
You must be signed in to change notification settings - Fork 9
/
Cakefile
47 lines (36 loc) · 1.29 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
fs = require 'fs'
{spawn, exec} = require 'child_process'
# ANSI Terminal Colors.
bold = red = green = reset = ''
unless process.env.NODE_DISABLE_COLORS
bold = '\x1B[0;1m'
red = '\x1B[0;31m'
green = '\x1B[0;32m'
reset = '\x1B[0m'
# Log a message with a color.
log = (message, color, explanation) ->
console.log color + message + reset + ' ' + (explanation or '')
# Build transformer from source.
build = (cb) ->
files = ['layout','mixin']
run 'mkdir', ['-p','bin', 'lib'], ->
compile files, 'src/', 'lib/', cb
compile = (srcFiles, srcDir, destDir, cb) ->
srcFilePaths = srcFiles.map (filename) -> "#{srcDir}/#{filename}.coffee"
args = ['--bare', '-o', destDir, '--compile'].concat srcFilePaths
coffee args, cb
# Run CoffeeScript command
coffee = (args, cb) -> run 'coffee', args, cb
run = (executable, args = [], cb) ->
proc = spawn executable, args
proc.stdout.on 'data', (buffer) -> log buffer.toString(), green
proc.stderr.on 'data', (buffer) -> log buffer.toString(), red
proc.on 'exit', (status) -> cb(status) if typeof cb is 'function'
test = ->
run 'tap', ['test'], (status) ->
if status == 0
log 'pass', green
else
log 'fail', red
task 'build', 'build react-layout from source', build
task 'test', 'test react-layout', test