#!/usr/bin/env node var program = require('commander'); var spawn = require('child_process').spawn; program .option('--forbid-only', 'Forbid only and pending filters.') .parse(process.argv); async function runTests(patterns) { return new Promise((resolve, reject) => { let mochaArgs = ['--require', 'ts-node/register', '--require', './spec-helper.js', '--colors']; if (program.forbidOnly) { mochaArgs = ['--forbid-only', '--forbid-pending'].concat(mochaArgs); } const mocha = spawn('./node_modules/.bin/mocha', mochaArgs.concat(patterns), { env: { ...process.env, 'TS_NODE_PROJECT': './server/tsconfig.json' } }); mocha.stdout.pipe(process.stdout); mocha.stderr.pipe(process.stderr); mocha.on('exit', (status) => { if (status == 0) { resolve(); } reject(new Error('Status code ' + status)); }); }); } async function test() { await runTests([ 'server/src/**/*.spec.ts', ]); } test() .then(() => { process.exit(0); }, (err) => { process.exit(1); });