Created
April 19, 2013 00:55
-
-
Save roman-neuhauser/5417376 to your computer and use it in GitHub Desktop.
roman-neuhauser/studio_napi/GNUmakefile redone as Cakefile. apparently not worth the effort.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{glob} = require 'multi-glob' | |
require './make' | |
split = (s) -> s.split /\s+/ | |
ENV = process.env | |
MOCHA = split (ENV.MOCHA or ''' | |
mocha -C --compilers t.coffee:coffee-script | |
--globals DELETE,GET,POST,PUT | |
''') | |
ENV.SHELL = SHELL = '/bin/sh' | |
RST2HTML = split (ENV.RST2HTML or "#{SHELL} tools/rst2html") | |
htmlfiles = split 'README.html NOTES.html examples.html reference.html' | |
testfiles = split 'tests/*.t.coffee tests/{lo,hi}/**/*.t.coffee' | |
e2efiles = split 'drive/*.t.coffee drive/{lo,hi}/**/*.t.coffee' | |
task 'wc', 'bootstrap the working copy', -> | |
$ 'npm', 'install' | |
$ 'false' | |
$ $ | |
$$ 'cat', 'bootstrap.note' | |
task 'html', 'generate HTML docs from reST sources', -> | |
for hf in htmlfiles | |
$ RST2HTML, (hf.replace /html$/, 'rest'), hf | |
task 'check', 'run unit tests', -> | |
$ 'npm', 'test' | |
task 'do-check', 'internal', -> | |
glob testfiles, safe (files) -> | |
$$ 'echo', MOCHA..., testfiles | |
$$ MOCHA, files... | |
task 'drive', 'run end-to-end tests', -> | |
$ 'npm', 'run-script', 'drive' | |
task 'do-drive', 'internal', -> | |
glob e2efiles, safe (files) -> | |
$$ MOCHA, '--timeout', '3000', files... | |
task 'clean', 'bring the working copy back to pristine state', -> | |
$ 'rm', '-f', htmlfiles... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{spawn} = require 'child_process' | |
exec = (silent) -> (cmd, args...) -> | |
@queue ||= [] | |
@queue.push => | |
console.log cmd, args... unless silent | |
child = spawn cmd, args | |
inprogress = 3 | |
finish = => | |
inprogress-- | |
if not inprogress | |
@queue.shift() | |
@queue[0]?() | |
child.on 'exit', (code) -> | |
if code | |
throw new Error "Error #{code} in #{cmd} #{args.join ' '}" | |
finish() | |
child.stdout.on 'end', finish | |
child.stderr.on 'end', finish | |
child.stdout.pipe process.stdout, end: false | |
child.stderr.pipe process.stderr, end: false | |
@queue[0]() if @queue.length is 1 | |
_ = (exec) -> (cmd, args...) -> | |
if args.length is 0 | |
if cmd is $ | |
return process.stdout.write "\n" | |
if cmd instanceof Array | |
[cmd, opts] = [cmd[0], cmd[1..]] | |
args = opts.concat args | |
exec cmd, args... | |
$$ = _ exec true | |
$ = _ exec false | |
safe = (f) -> (err, args...) -> | |
throw err if err | |
f args... | |
global.$ = $ | |
global.$$ = $$ | |
global.safe = safe |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment