From 3eeeec31e4ec30776cea1710f6cbaaa8a3ac620d Mon Sep 17 00:00:00 2001 From: Pascal Precht Date: Fri, 1 Feb 2019 14:11:40 +0100 Subject: [PATCH] fix(@embark/solidity): fix binding in method call This commit fixes a bug where it throws while trying to compile solidity files as it dereferences its `this`. Unfortunately passing methods as lambda callbacks doesn't correctly resolve its `this` scope even within fat arrow functions, resulting in unexpected behaviour where `this` inside lambda is `undefined`. --- src/lib/modules/solidity/solcP.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/modules/solidity/solcP.js b/src/lib/modules/solidity/solcP.js index 3a5ed860b..70bc9aa6c 100644 --- a/src/lib/modules/solidity/solcP.js +++ b/src/lib/modules/solidity/solcP.js @@ -67,7 +67,7 @@ class SolcProcess extends ProcessWrapper { if (semver.gte(this.solc.version(), '0.5.0')) { func = this.solc.compile; } - let output = func(JSON.stringify(jsonObj), this.findImports); + let output = func(JSON.stringify(jsonObj), this.findImports.bind(this)); cb(null, output); } catch (err) { cb(err.message);