mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
49 lines
1.1 KiB
JavaScript
Executable File
49 lines
1.1 KiB
JavaScript
Executable File
#!/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',
|
|
'shared/**/*.spec.ts'
|
|
]);
|
|
}
|
|
|
|
test()
|
|
.then(() => {
|
|
process.exit(0);
|
|
}, (err) => {
|
|
process.exit(1);
|
|
});
|
|
|