Skip to content

Commit 4beb02e

Browse files
authored
Merge pull request #41 from sc-forks/permit-non-truffle
Stop crashing on encounters with non-truffle projects
2 parents 1c2d328 + c7a2376 commit 4beb02e

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

bin/exec.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ try {
8383
shell.cp('-R', `${workingDir}/test`, `${coverageDir}`);
8484
shell.cp('-R', `${workingDir}/migrations`, `${coverageDir}`);
8585

86-
const truffleConfig = reqCwd(`${workingDir}/truffle.js`);
86+
const truffleConfig = reqCwd.silent(`${workingDir}/truffle.js`);
8787

8888
// Coverage network opts specified: copy truffle.js whole to coverage environment
89-
if (truffleConfig.networks.coverage) {
89+
if (truffleConfig && truffleConfig.networks && truffleConfig.networks.coverage) {
9090
port = truffleConfig.networks.coverage.port || port;
9191
shell.cp(`${workingDir}/truffle.js`, `${coverageDir}/truffle.js`);
9292

@@ -142,21 +142,20 @@ try {
142142
cleanUp(msg + err);
143143
}
144144

145-
// Set testrpc options
146-
const defaultRpcOptions = `--gasLimit ${gasLimitString} --accounts ${accounts} --port ${port}`;
147-
const testrpcOptions = config.testrpcOptions || defaultRpcOptions;
148-
149145
// Run modified testrpc with large block limit, on (hopefully) unused port.
150146
// (Changes here should be also be added to the before() block of test/run.js).
151147
if (!config.norpc) {
148+
const defaultRpcOptions = `--gasLimit ${gasLimitString} --accounts ${accounts} --port ${port}`;
149+
const testrpcOptions = config.testrpcOptions || defaultRpcOptions;
152150
const command = './node_modules/.bin/testrpc-sc ';
151+
153152
testrpcProcess = childprocess.exec(command + testrpcOptions, null, err => {
154153
if (err) cleanUp('testRpc errored after launching as a childprocess.');
155154
});
156155
log(`Launching testrpc on port ${port}`);
157156
}
158157

159-
// Run truffle over instrumented contracts in the
158+
// Run truffle (or config.testCommand) over instrumented contracts in the
160159
// coverage environment folder. Shell cd command needs to be invoked
161160
// as its own statement for command line options to work, apparently.
162161
try {

0 commit comments

Comments
 (0)