summaryrefslogtreecommitdiff
path: root/.bin/mocha
blob: 811ed9d807fe3f4c3b4d3fd652572df9a5bce2e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env node

/**
 * This tiny wrapper file checks for known node flags and appends them
 * when found, before invoking the "real" _mocha(1) executable.
 */

var spawn = require('child_process').spawn
  , args = [ __dirname + '/_mocha' ];

process.argv.slice(2).forEach(function (arg) {
  switch (arg) {
    case '-d':
      args.unshift('--debug');
      break;
    case 'debug':
    case '--debug':
    case '--debug-brk':
      args.unshift(arg);
      break;
    case '-gc':
    case '--expose-gc':
      args.unshift('--expose-gc');
      break;
    default:
      args.push(arg);
      break;
  }
});

var proc = spawn(process.argv[0], args, { customFds: [0,1,2] });
proc.on('exit', process.exit);