From e0fd641df930d7e7dc1861127d64f6468ca683b0 Mon Sep 17 00:00:00 2001 From: emizzle Date: Fri, 1 Feb 2019 10:00:41 +1100 Subject: [PATCH] fix(@embark/core): fix(@embark/core): Fix recursive import remapping MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remapping of imports was failing if the file had already had it’s import replaced with a pattern that would match with subsequent replacement attempts. For example, if the dapp contract contained ``` import ".embark/node_modules/zeppelin-solidity/contracts/ownership/Ownable.sol”; ``` which lives in `node_modules`, then `zeppelin-solidity/contracts/ownership/Ownable.sol` would be replaced with `.embark/node_modules/zeppelin-solidity/contracts/ownership/Ownable.sol`, resulting in: ``` import ".embark/node_modules/zeppelin-solidity/contracts/ownership/Ownable.sol"; ``` On subsequent replacements of the same file, the same replacement would occur, resulting in the incorrect ``` import ".embark/node_modules/.embark/node_modules/zeppelin-solidity/contracts/ownership/Ownable.sol"; ``` --- src/lib/utils/solidity/remapImports.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/utils/solidity/remapImports.ts b/src/lib/utils/solidity/remapImports.ts index c64f9d1b6..d12cf5ed4 100644 --- a/src/lib/utils/solidity/remapImports.ts +++ b/src/lib/utils/solidity/remapImports.ts @@ -128,7 +128,7 @@ const replaceImports = (remapImports: RemapImport[]) => { Object.keys(byPath).forEach((p) => { let source = fs.readFileSync(p, "utf-8"); byPath[p].forEach(({searchValue, replaceValue}) => { - source = source.replace(`${searchValue}`, `${replaceValue}`); + source = source.replace(`import "${searchValue}"`, `import "${replaceValue}"`); }); fs.writeFileSync(p, source); });