-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathrun-tests
executable file
·36 lines (31 loc) · 1013 Bytes
/
run-tests
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env babel-node
/* eslint no-process-exit: 0 */
import chalk from 'chalk';
import { exec, spawn } from 'child-process-promise';
const isCI = process.env.CONTINUOUS_INTEGRATION === 'true';
function myspawn(command) {
console.log(`> ${command}\n`);
let [cmd, ...args] = command.split(' ');
return spawn(cmd, args, {stdio: 'inherit'})
.then(() => console.log(''));
}
myspawn('npm run lint')
.then(() => myspawn('mocha --compilers js:babel-core/register'))
.then(() => {
console.log(chalk.cyan('Gathering Code Coverage...\n'));
return exec('rm -rf ./.coverage');
})
.then(() => myspawn('babel-node node_modules/babel-istanbul/lib/cli.js cover node_modules/mocha/bin/_mocha -- --reporter dot'))
.then(() => {
if (isCI) {
return exec(`cat ./.coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js`);
}
})
.catch(err => {
if (err.stack) {
console.error(err.stack);
} else {
console.error(err);
}
process.exit(1);
});