mirror of
https://github.com/embarklabs/embark.git
synced 2025-02-05 02:14:35 +00:00
fix(@embark/core): fix(@embark/core): Fix recursive import remapping
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"; ```
This commit is contained in:
parent
0ddebc7a80
commit
e0fd641df9
@ -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);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user