UNPKG

849 BJavaScriptView Raw
1
2/**
3 * Module dependencies.
4 */
5
6var path = require('path');
7var spawn = require('child_process').spawn;
8
9// node executable
10var node = process.execPath || process.argv[0];
11var gnode = path.resolve(__dirname, '..', 'bin', 'gnode');
12var mocha = path.resolve(__dirname, '..', 'node_modules', '.bin', 'mocha');
13var mochaOpts = [ '--reporter', 'spec' ];
14
15run([
16 [ mocha, path.resolve(__dirname, 'cli.js') ]
17]);
18
19function run (tests) {
20 if (0 == tests.length) return;
21 var argv = tests.shift();
22 if (argv.indexOf(mocha) != -1) {
23 // running mocha, append "mochaOpts"
24 argv.push.apply(argv, mochaOpts);
25 }
26 var opts = {
27 customFds: [ 0, 1, 2 ],
28 stdio: 'inherit'
29 };
30 var child = spawn(node, argv, opts);
31 child.on('exit', function (code) {
32 if (0 == code) {
33 run(tests);
34 } else {
35 process.exit(code);
36 }
37 });
38}