aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-11-23 21:16:58 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-12-03 19:09:28 +0800
commiteefb1cfe5d77ed62aa3d703d810a55d133fe024b (patch)
treed470fd75822f3d1dca0262505a01764a7cf57aef
parent5b0746a8efdad0250897ef255ea9fab7bd14deb5 (diff)
downloaddexon-sol-tools-eefb1cfe5d77ed62aa3d703d810a55d133fe024b.tar
dexon-sol-tools-eefb1cfe5d77ed62aa3d703d810a55d133fe024b.tar.gz
dexon-sol-tools-eefb1cfe5d77ed62aa3d703d810a55d133fe024b.tar.bz2
dexon-sol-tools-eefb1cfe5d77ed62aa3d703d810a55d133fe024b.tar.lz
dexon-sol-tools-eefb1cfe5d77ed62aa3d703d810a55d133fe024b.tar.xz
dexon-sol-tools-eefb1cfe5d77ed62aa3d703d810a55d133fe024b.tar.zst
dexon-sol-tools-eefb1cfe5d77ed62aa3d703d810a55d133fe024b.zip
Fix an issue when we tried to append base contracts path to absolute imports (NPM) in sol-compiler
-rw-r--r--packages/sol-compiler/CHANGELOG.json9
-rw-r--r--packages/sol-compiler/src/compiler.ts9
2 files changed, 17 insertions, 1 deletions
diff --git a/packages/sol-compiler/CHANGELOG.json b/packages/sol-compiler/CHANGELOG.json
index e9274f64e..490e88d22 100644
--- a/packages/sol-compiler/CHANGELOG.json
+++ b/packages/sol-compiler/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "1.1.15",
+ "changes": [
+ {
+ "note": "Fix an issue when we tried to append base contracts path to absolute imports (NPM)",
+ "pr": 1311
+ }
+ ]
+ },
+ {
"timestamp": 1543401373,
"version": "1.1.14",
"changes": [
diff --git a/packages/sol-compiler/src/compiler.ts b/packages/sol-compiler/src/compiler.ts
index 8ee7fa4a9..c5b6497df 100644
--- a/packages/sol-compiler/src/compiler.ts
+++ b/packages/sol-compiler/src/compiler.ts
@@ -394,7 +394,14 @@ export class Compiler {
//
const lastPathSeparatorPos = contractPath.lastIndexOf('/');
const contractFolder = lastPathSeparatorPos === -1 ? '' : contractPath.slice(0, lastPathSeparatorPos + 1);
- importPath = path.resolve('/' + contractFolder, importPath).replace('/', '');
+ if (importPath.startsWith('.')) {
+ /**
+ * Some imports path are relative ("../Token.sol", "./Wallet.sol")
+ * while others are absolute ("Token.sol", "@0x/contracts/Wallet.sol")
+ * And we need to do the hack mentooned above only for relative imports.
+ */
+ importPath = path.resolve('/' + contractFolder, importPath).replace('/', '');
+ }
if (_.isUndefined(sourcesToAppendTo[importPath])) {
sourcesToAppendTo[importPath] = { id: fullSources[importPath].id };