From 4821997866f25314964da17a9570519c68932be5 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Sun, 12 Aug 2018 17:10:49 -0500 Subject: [PATCH] resolve ganache-cli bin using pkg-up --- lib/modules/blockchain_process/simulator.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/modules/blockchain_process/simulator.js b/lib/modules/blockchain_process/simulator.js index 4ff64ab2..5d03f1ef 100644 --- a/lib/modules/blockchain_process/simulator.js +++ b/lib/modules/blockchain_process/simulator.js @@ -1,4 +1,5 @@ const path = require('path'); +const pkgUp = require('pkg-up'); let shelljs = require('shelljs'); let proxy = require('./proxy'); const Ipc = require('../../core/ipc'); @@ -14,7 +15,16 @@ class Simulator { run(options) { let cmds = []; - const ganache = path.join(__dirname, '../../../node_modules/.bin/ganache-cli'); + const ganache_main = require.resolve('ganache-cli'); + const ganache_json = pkgUp.sync(path.dirname(ganache_main)); + const ganache_root = path.dirname(ganache_json); + const ganache_bin = require(ganache_json).bin; + let ganache; + if (typeof ganache_bin === 'string') { + ganache = path.join(ganache_root, ganache_bin); + } else { + ganache = path.join(ganache_root, ganache_bin['ganache-cli']); + } let useProxy = this.blockchainConfig.proxy || false; let host = (dockerHostSwap(options.host || this.blockchainConfig.rpcHost) || defaultHost);