From 826d9d59e828a807128bae9076850c3a5c3c8752 Mon Sep 17 00:00:00 2001 From: cgewecke Date: Fri, 6 Sep 2019 00:31:11 -0700 Subject: [PATCH] Handle truffle provider config restrictions & process killing --- dist/truffle.plugin.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/dist/truffle.plugin.js b/dist/truffle.plugin.js index 57a0025..c41d7f1 100644 --- a/dist/truffle.plugin.js +++ b/dist/truffle.plugin.js @@ -27,6 +27,7 @@ const App = require('./../lib/app'); const req = require('req-cwd'); +const death = require('death'); const path = require('path'); const dir = require('node-dir'); const Web3 = require('web3'); @@ -50,6 +51,7 @@ async function plugin(truffleConfig){ // Start app = new App(coverageConfig); + death(app.cleanUp); // Write instrumented sources to temp folder app.instrument(); @@ -72,12 +74,18 @@ async function plugin(truffleConfig){ const provider = await app.provider(ganache); const accounts = await (new Web3(provider)).eth.getAccounts(); - truffleConfig.provider = provider; truffleConfig.network = networkName; - truffleConfig.network_id = "*"; + + // Truffle alternately complains that fields are and + // are not manually set + try { + truffleConfig.network_id = "*"; + truffleConfig.provider = provider; + } catch (err){} + truffleConfig.networks[networkName] = { - network_id: truffleConfig.network_id, - provider: truffleConfig.provider, + network_id: "*", + provider: provider, gas: app.gasLimit, gasPrice: app.gasPrice, from: accounts[0]