|
|
@ -34,6 +34,7 @@ const dir = require('node-dir'); |
|
|
|
const Web3 = require('web3'); |
|
|
|
const Web3 = require('web3'); |
|
|
|
const util = require('util'); |
|
|
|
const util = require('util'); |
|
|
|
const globby = require('globby'); |
|
|
|
const globby = require('globby'); |
|
|
|
|
|
|
|
const globalModules = require('global-modules'); |
|
|
|
|
|
|
|
|
|
|
|
async function plugin(truffleConfig){ |
|
|
|
async function plugin(truffleConfig){ |
|
|
|
let app; |
|
|
|
let app; |
|
|
@ -59,7 +60,7 @@ async function plugin(truffleConfig){ |
|
|
|
return app.ui.report('truffle-help') |
|
|
|
return app.ui.report('truffle-help') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
truffle = loadTruffleLibrary(); |
|
|
|
truffle = loadTruffleLibrary(app); |
|
|
|
|
|
|
|
|
|
|
|
} catch (err) { |
|
|
|
} catch (err) { |
|
|
|
throw err; |
|
|
|
throw err; |
|
|
@ -152,13 +153,36 @@ function tests(truffle){ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function loadTruffleLibrary(){ |
|
|
|
function loadTruffleLibrary(app){ |
|
|
|
try { return require("truffle") } catch(err) {}; |
|
|
|
|
|
|
|
try { return require("./truffle.library")} catch(err) {}; |
|
|
|
// Case: from local node_modules
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
const lib = require("truffle"); |
|
|
|
|
|
|
|
app.ui.report('truffle-local'); |
|
|
|
|
|
|
|
return lib; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch(err) {}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Case: global
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
const globalTruffle = path.join(globalModules, 'truffle'); |
|
|
|
|
|
|
|
const lib = require(globalTruffle); |
|
|
|
|
|
|
|
app.ui.report('truffle-global'); |
|
|
|
|
|
|
|
return lib; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch(err) {}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Default: fallback
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.ui.report('truffle-warn'); |
|
|
|
|
|
|
|
return require("./truffle.library")} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
catch(err) { |
|
|
|
|
|
|
|
const msg = app.ui.generate('truffle-fail', [err]); |
|
|
|
|
|
|
|
throw new Error(msg); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// TO DO: throw error? This point should never be reached.
|
|
|
|
|
|
|
|
// Validate that truffle.ganache exists? Have checked that
|
|
|
|
|
|
|
|
// a non-existent prop defaults to the ganache-core-sc fallback FWIW.
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|