From f02cb7689e60bd12c48083c47c2233f99bb3b713 Mon Sep 17 00:00:00 2001 From: cgewecke Date: Sun, 5 Nov 2017 17:24:52 -0800 Subject: [PATCH] Add sanity checks for contracts and coverageEnv folders --- lib/app.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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