From c7a237678841b9e8fca6b86c90476a3b47398063 Mon Sep 17 00:00:00 2001 From: cgewecke Date: Wed, 21 Jun 2017 16:12:57 -0700 Subject: [PATCH] Stop crashing on encounters with non-truffle projects --- bin/exec.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/bin/exec.js b/bin/exec.js index 3df2650..562322e 100644 --- a/bin/exec.js +++ b/bin/exec.js @@ -83,10 +83,10 @@ try { shell.cp('-R', `${workingDir}/test`, `${coverageDir}`); shell.cp('-R', `${workingDir}/migrations`, `${coverageDir}`); - const truffleConfig = reqCwd(`${workingDir}/truffle.js`); + const truffleConfig = reqCwd.silent(`${workingDir}/truffle.js`); // Coverage network opts specified: copy truffle.js whole to coverage environment - if (truffleConfig.networks.coverage) { + if (truffleConfig && truffleConfig.networks && truffleConfig.networks.coverage) { port = truffleConfig.networks.coverage.port || port; shell.cp(`${workingDir}/truffle.js`, `${coverageDir}/truffle.js`); @@ -142,21 +142,20 @@ try { cleanUp(msg + err); } -// Set testrpc options -const defaultRpcOptions = `--gasLimit ${gasLimitString} --accounts ${accounts} --port ${port}`; -const testrpcOptions = config.testrpcOptions || defaultRpcOptions; - // Run modified testrpc with large block limit, on (hopefully) unused port. // (Changes here should be also be added to the before() block of test/run.js). if (!config.norpc) { + const defaultRpcOptions = `--gasLimit ${gasLimitString} --accounts ${accounts} --port ${port}`; + const testrpcOptions = config.testrpcOptions || defaultRpcOptions; const command = './node_modules/.bin/testrpc-sc '; + testrpcProcess = childprocess.exec(command + testrpcOptions, null, err => { if (err) cleanUp('testRpc errored after launching as a childprocess.'); }); log(`Launching testrpc on port ${port}`); } -// Run truffle over instrumented contracts in the +// Run truffle (or config.testCommand) over instrumented contracts in the // coverage environment folder. Shell cd command needs to be invoked // as its own statement for command line options to work, apparently. try {