Skip to content

Commit

Permalink
NODE - safer watch mode (#115)
Browse files Browse the repository at this point in the history
Move the `try catch` to also handle src files
  • Loading branch information
stoffeastrom committed Dec 19, 2017
1 parent 1fab90a commit ff31740
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,9 @@ class Runner {
}
runTests() {
this.isRunning = true;
try {
this.mochaRunner = this.mocha.run(failures => this.onFinished(failures));
this.mochaRunner.on('start', () => this.logClearLine());
this.mochaRunner.on('end', () => this.onEnd());
} catch (err) {
this.isRunning = false;
console.log(err);
if (this.argv.watch) {
return;
}
process.exit(1);
}
this.mochaRunner = this.mocha.run(failures => this.onFinished(failures));
this.mochaRunner.on('start', () => this.logClearLine());
this.mochaRunner.on('end', () => this.onEnd());
}
setupKeyPress() {
if (!this.argv.watch) {
Expand Down Expand Up @@ -226,10 +217,19 @@ class Runner {
this.logLine(`Loading ${file}`);
});
this.nyc = new this.libs.NYC(this.argv.nyc);
this
.deleteCoverage()
.setup(testFiles, srcFiles)
.runTests();
try {
this
.deleteCoverage()
.setup(testFiles, srcFiles)
.runTests();
} catch (err) {
this.isRunning = false;
console.log(err);
if (this.argv.watch) {
return;
}
process.exit(1);
}
}
onWatchAdd(f) {
const base = path.basename(f);
Expand Down

0 comments on commit ff31740

Please sign in to comment.