UNPKG

827 BPlain TextView Raw
1#!/usr/bin/env node
2
3'use strict';
4
5var path = require('path');
6var spawn = require('child_process').spawn;
7
8var MOCHA_PATH = require.resolve('mocha/bin/mocha');
9var args = [
10 MOCHA_PATH,
11 '-r',
12 path.join(__dirname, '../src/index.js'),
13];
14
15process.argv.slice(2).forEach(function (arg, idx, arr) {
16 switch (arg) {
17 case '-p':
18 case '--project':
19 process.env.__TS_PROJECT_PATH__ = arr[idx + 1];
20 break;
21 default:
22 args.push(arg);
23 break;
24 }
25});
26
27var mocha = spawn(process.execPath, args, {
28 stdio: 'inherit',
29});
30mocha.on('exit', function (code, signal) {
31 process.on('exit', function () {
32 if (signal) {
33 process.kill(process.pid, signal);
34 } else {
35 process.exit(code);
36 }
37 });
38});
39
40process.on('SIGINT', function () {
41 mocha.kill('SIGINT');
42 mocha.kill('SIGTERM');
43});
\No newline at end of file