2019-02-22 16:27:54 +07:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
var program = require('commander');
|
|
|
|
var spawn = require('child_process').spawn;
|
|
|
|
|
|
|
|
program
|
2019-03-18 15:27:41 +07:00
|
|
|
.option('--forbid-only', 'Forbid only and pending filters.')
|
2019-02-22 16:27:54 +07:00
|
|
|
.parse(process.argv);
|
|
|
|
|
2019-03-18 15:27:41 +07:00
|
|
|
async function runTests(patterns) {
|
2019-02-22 16:27:54 +07:00
|
|
|
return new Promise((resolve, reject) => {
|
2019-03-18 15:27:41 +07:00
|
|
|
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), {
|
2019-02-22 16:27:54 +07:00
|
|
|
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() {
|
2019-03-18 15:27:41 +07:00
|
|
|
await runTests([
|
|
|
|
'server/src/**/*.spec.ts',
|
|
|
|
]);
|
2019-02-22 16:27:54 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
test()
|
|
|
|
.then(() => {
|
|
|
|
process.exit(0);
|
|
|
|
}, (err) => {
|
|
|
|
process.exit(1);
|
|
|
|
});
|
|
|
|
|