diff --git a/lib/app.js b/lib/app.js index 2ead507..5fb14d1 100644 --- a/lib/app.js +++ b/lib/app.js @@ -57,6 +57,8 @@ class App { this.log('Generating coverage environment'); try { + this.sanityCheckContext(); + let files = shell.ls(this.workingDir); const nmIndex = files.indexOf('node_modules'); @@ -188,7 +190,7 @@ class App { ` There was an error generating coverage. Possible reasons include: 1. Another application is using port ${this.port} - 2. Truffle crashed because your tests errored + 2. Your test runner (Truffle?) crashed because the tests encountered an error. `; this.cleanUp(msg + err); @@ -240,6 +242,16 @@ class App { // ------------------------------------------ Utils ---------------------------------------------- + sanityCheckContext(){ + if (!shell.test('-e', `${this.workingDir}/contracts`)){ + this.cleanUp("Couldn't find a 'contracts' folder to instrument."); + } + + if (shell.test('-e', `${this.workingDir}/${this.coverageDir}`)){ + shell.rm('-Rf', this.coverageDir); + } + } + /** * Relativizes path keys so that istanbul report can be read on Windows * @param {Object} map coverage map generated by coverageMap