Merge pull request #796 from embark-framework/bug_fix/web3-location

getWeb3Location should use require.resolve()
This commit is contained in:
Iuri Matias 2018-09-07 19:03:59 -04:00 committed by GitHub
commit 4128a96997
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -5,6 +5,7 @@ let proxy = require('./proxy');
const Ipc = require('../../core/ipc'); const Ipc = require('../../core/ipc');
const constants = require('../../constants.json'); const constants = require('../../constants.json');
const {defaultHost, dockerHostSwap} = require('../../utils/host'); const {defaultHost, dockerHostSwap} = require('../../utils/host');
const fs = require('../../core/fs.js');
class Simulator { class Simulator {
constructor(options) { constructor(options) {
@ -15,7 +16,7 @@ class Simulator {
run(options) { run(options) {
let cmds = []; let cmds = [];
const ganache_main = require.resolve('ganache-cli'); const ganache_main = require.resolve('ganache-cli', {paths: fs.embarkPath('node_modules')});
const ganache_json = pkgUp.sync(path.dirname(ganache_main)); const ganache_json = pkgUp.sync(path.dirname(ganache_main));
const ganache_root = path.dirname(ganache_json); const ganache_root = path.dirname(ganache_json);
const ganache_bin = require(ganache_json).bin; const ganache_bin = require(ganache_json).bin;

View File

@ -289,7 +289,7 @@ class CodeGenerator {
function getWeb3Location(next) { function getWeb3Location(next) {
self.events.request("version:get:web3", function(web3Version) { self.events.request("version:get:web3", function(web3Version) {
if (web3Version === "1.0.0-beta") { if (web3Version === "1.0.0-beta") {
return next(null, fs.embarkPath("node_modules/web3")); return next(null, require.resolve("web3", {paths: fs.embarkPath("node_modules")}));
} }
self.events.request("version:getPackageLocation", "web3", web3Version, function(err, location) { self.events.request("version:getPackageLocation", "web3", web3Version, function(err, location) {
return next(null, fs.dappPath(location)); return next(null, fs.dappPath(location));
@ -350,7 +350,7 @@ class CodeGenerator {
function getWeb3Location(next) { function getWeb3Location(next) {
self.events.request("version:get:web3", function(web3Version) { self.events.request("version:get:web3", function(web3Version) {
if (web3Version === "1.0.0-beta") { if (web3Version === "1.0.0-beta") {
return next(null, utils.joinPath(fs.embarkPath("node_modules/web3"))); return next(null, require.resolve("web3", {paths: fs.embarkPath("node_modules")}));
} }
self.events.request("version:getPackageLocation", "web3", web3Version, function(err, location) { self.events.request("version:getPackageLocation", "web3", web3Version, function(err, location) {
return next(null, fs.dappPath(location)); return next(null, fs.dappPath(location));