Fix an issue when we tried to append base contracts path to absolute imports (NPM) in sol-compiler
This commit is contained in:
@@ -1,4 +1,13 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"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,
|
"timestamp": 1543401373,
|
||||||
"version": "1.1.14",
|
"version": "1.1.14",
|
||||||
|
@@ -394,7 +394,14 @@ export class Compiler {
|
|||||||
//
|
//
|
||||||
const lastPathSeparatorPos = contractPath.lastIndexOf('/');
|
const lastPathSeparatorPos = contractPath.lastIndexOf('/');
|
||||||
const contractFolder = lastPathSeparatorPos === -1 ? '' : contractPath.slice(0, lastPathSeparatorPos + 1);
|
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])) {
|
if (_.isUndefined(sourcesToAppendTo[importPath])) {
|
||||||
sourcesToAppendTo[importPath] = { id: fullSources[importPath].id };
|
sourcesToAppendTo[importPath] = { id: fullSources[importPath].id };
|
||||||
|
Reference in New Issue
Block a user