Skip to content

Commit 7d1e6ac

Browse files
committed
Handle truffle provider config restrictions & process killing
1 parent 1d093e9 commit 7d1e6ac

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

dist/truffle.plugin.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
const App = require('./../lib/app');
2929
const req = require('req-cwd');
30+
const death = require('death');
3031
const path = require('path');
3132
const dir = require('node-dir');
3233
const Web3 = require('web3');
@@ -50,6 +51,7 @@ async function plugin(truffleConfig){
5051

5152
// Start
5253
app = new App(coverageConfig);
54+
death(app.cleanUp);
5355

5456
// Write instrumented sources to temp folder
5557
app.instrument();
@@ -72,12 +74,18 @@ async function plugin(truffleConfig){
7274
const provider = await app.provider(ganache);
7375
const accounts = await (new Web3(provider)).eth.getAccounts();
7476

75-
truffleConfig.provider = provider;
7677
truffleConfig.network = networkName;
77-
truffleConfig.network_id = "*";
78+
79+
// Truffle alternately complains that fields are and
80+
// are not manually set
81+
try {
82+
truffleConfig.network_id = "*";
83+
truffleConfig.provider = provider;
84+
} catch (err){}
85+
7886
truffleConfig.networks[networkName] = {
79-
network_id: truffleConfig.network_id,
80-
provider: truffleConfig.provider,
87+
network_id: "*",
88+
provider: provider,
8189
gas: app.gasLimit,
8290
gasPrice: app.gasPrice,
8391
from: accounts[0]

0 commit comments

Comments
 (0)