UNPKG

1.03 kBPlain TextView Raw
1#!/usr/bin/env node
2// vim: set filetype=javascript:
3
4// this is a simple wrapper around the mocha executable, with the test
5// files location (and coffeescript support) automatically provided.
6
7var spawn = require('child_process').spawn,
8 path = require('path');
9
10// TODO: handle -h/--help
11var args = [path.resolve(__dirname, '../test/*.coffee'),
12 '--reporter', 'spec',
13 '--compilers', 'coffee:coffee-script/register'];
14args = args.concat(process.argv.slice(2));
15
16// code below is taken from the mocha executable:
17var proc = spawn('_mocha', args, { stdio: 'inherit' });
18proc.on('exit', function (code, signal) {
19 process.on('exit', function(){
20 if (signal) {
21 process.kill(process.pid, signal);
22 } else {
23 process.exit(code);
24 }
25 });
26});
27
28// terminate children.
29process.on('SIGINT', function () {
30 proc.kill('SIGINT'); // calls runner.abort()
31 proc.kill('SIGTERM'); // if that didn't work, we're probably in an infinite loop, so make it die.
32 process.kill(process.pid, 'SIGINT');
33});