UNPKG

1.1 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// TODO: handle -h/--help
10var args = [
11 path.resolve(process.cwd(), './node_modules/.bin/_mocha'),
12 path.resolve(__dirname, '../test/*.js'),
13 '--reporter',
14 'spec'
15];
16args = args.concat(process.argv.slice(2));
17
18// code below is taken from the mocha executable:
19// (we use node as the first argument so that this works on windows)
20var proc = spawn(process.execPath, args, { stdio: 'inherit' });
21proc.on('exit', function (code, signal) {
22 process.on('exit', function(){
23 if (signal) {
24 process.kill(process.pid, signal);
25 } else {
26 process.exit(code);
27 }
28 });
29});
30
31// terminate children.
32process.on('SIGINT', function () {
33 proc.kill('SIGINT'); // calls runner.abort()
34 proc.kill('SIGTERM'); // if that didn't work, we're probably in an infinite loop, so make it die.
35 process.kill(process.pid, 'SIGINT');
36});