-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for #14. Use prepublish script to build 'lib'. Add some unit test…
… infrastructure.
- Loading branch information
Jason Walton
committed
Jan 20, 2014
1 parent
eac2204
commit 93acad8
Showing
13 changed files
with
156 additions
and
724 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
/testdir | ||
/node_modules | ||
/lib |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/node_modules |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,45 @@ | ||
{exec} = require 'child_process' | ||
{spawn, exec} = require 'child_process' | ||
|
||
task 'build', "Build project from src/*.coffee to lib/*.js", -> | ||
exec 'coffee --compile --output lib/ src/', (err, stdout, stderr) -> | ||
throw err if err | ||
process.stdout.write stdout | ||
process.stderr.write stderr | ||
launch = (cmd, options=[], done=null) -> | ||
app = spawn cmd, options | ||
app.stdout.pipe(process.stdout) | ||
app.stderr.pipe(process.stderr) | ||
app.on 'exit', (status) -> | ||
err = if status isnt 0 then new Error("Error running #{cmd}") else null | ||
done? err | ||
|
||
build = (done) -> | ||
console.log "Building" | ||
exec './node_modules/.bin/coffee --compile --output lib/ src/', (err, stdout, stderr) -> | ||
process.stderr.write stderr | ||
return done err if err | ||
|
||
process.stderr.write stderr | ||
done?() | ||
|
||
mocha = (done) -> | ||
console.log "Testing" | ||
|
||
options = [] | ||
options.push '--compilers' | ||
options.push 'coffee:coffee-script' | ||
|
||
# Colors! | ||
options.push '-c' | ||
|
||
# Run everything in the `test` folder. | ||
options.push '--recursive' | ||
options.push 'test' | ||
|
||
options.push '--reporter' | ||
options.push 'spec' | ||
|
||
launch './node_modules/.bin/mocha', options, done | ||
|
||
run = (fn) -> | ||
-> | ||
fn (err) -> | ||
console.log err.stack if err | ||
|
||
task 'build', "Build project from src/*.coffee to lib/*.js", run build | ||
task 'test', "Run mocha tests", run -> build mocha |
Oops, something went wrong.