Skip to content

Commit

Permalink
Swapped Makefile for Cakefile providing better cross-platform support
Browse files Browse the repository at this point in the history
  • Loading branch information
balupton committed Jan 24, 2013
1 parent 7a507fd commit 0fc0aa8
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 64 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
language: node_js
before_script: "make test-prepare"
install: "npm install"
before_script: "./node_modules/.bin/cake test-prepare"
script: "./node_modules/.bin/cake test"
node_js:
- 0.6
- 0.8
Expand Down
118 changes: 118 additions & 0 deletions Cakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# This file was originally created by Benjamin Lupton <b@lupton.cc> (http://balupton.com)
# and is currently licensed under the Creative Commons Zero (http://creativecommons.org/publicdomain/zero/1.0/)
# making it public domain so you can do whatever you wish with it without worry (you can even remove this notice!)
#
# If you change something here, be sure to reflect the changes in:
# - the scripts section of the package.json file
# - the .travis.yml file


# -----------------
# Variables

WINDOWS = process.platform.indexOf('win') is 0
NODE = process.execPath
NPM = if WINDOWS then process.execPath.replace('node.exe','npm.cmd') else 'npm'
EXT = (if WINDOWS then '.cmd' else '')
APP = process.cwd()
BIN = "#{APP}/node_modules/.bin"
CAKE = "#{BIN}/cake#{EXT}"
COFFEE = "#{BIN}/coffee#{EXT}"
OUT = "#{APP}/out"
SRC = "#{APP}/src"


# -----------------
# Requires

{exec,spawn} = require('child_process')
safe = (next,fn) ->
return (err) ->
return next(err) if err
return fn()


# -----------------
# Actions

clean = (opts,next) ->
(next = opts; opts = {}) unless next?
exec("rm -Rf #{OUT} node_modules *out *.log", {stdio:'inherit',cwd:APP}, next)

compile = (opts,next) ->
(next = opts; opts = {}) unless next?
spawn(COFFEE, ['-co', OUT, SRC], {stdio:'inherit',cwd:APP}).on('exit',next)

watch = (opts,next) ->
(next = opts; opts = {}) unless next?
spawn(COFFEE, ['-wco', OUT, SRC], {stdio:'inherit',cwd:APP}).on('exit',next)

install = (opts,next) ->
(next = opts; opts = {}) unless next?
spawn(NPM, ['install'], {stdio:'inherit',cwd:APP}).on('exit',next)

reset = (opts,next) ->
(next = opts; opts = {}) unless next?
clean opts, safe next, ->
install opts, safe next, ->
compile opts, next

setup = (opts,next) ->
(next = opts; opts = {}) unless next?
install opts, safe next, ->
compile opts, next

test = (opts,next) ->
(next = opts; opts = {}) unless next?
args = []
args.push("--debug-brk") if opts.debug
args.push("#{OUT}/test/everything.test.js")
args.push("--joe-reporter=list")
spawn(NODE, args, {stdio:'inherit',cwd:APP}, next)

finish = (err) ->
throw err if err
console.log('OK')


# -----------------
# Commands

# clean
task 'clean', 'clean up instance', ->
clean finish

# compile
task 'compile', 'compile our files', ->
compile finish

# dev/watch
task 'dev', 'watch and recompile our files', ->
watch finish
task 'watch', 'watch and recompile our files', ->
watch finish

# install
task 'install', 'install dependencies', ->
install finish

# reset
task 'reset', 'reset instance', ->
reset finish

# setup
task 'setup', 'setup for development', ->
setup finish

# test
task 'test', 'run our tests', ->
test finish

# test-debug
task 'test-debug', 'run our tests in debug mode', ->
test {debug:true}, finish

# test-prepare
task 'test-prepare', 'prepare out tests', ->
setup finish

62 changes: 0 additions & 62 deletions Makefile

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"lib": "./out/lib"
},
"scripts": {
"test": "node ./out/test/everything.test.js --joe-reporter=console"
"test": "./node_modules/.bin/cake test"
},
"main": "./out/lib/balutil"
}

0 comments on commit 0fc0aa8

Please sign in to comment.