diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2019-01-28 23:24:54 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2019-01-29 00:24:44 +0800 |
commit | 0c12128f64f7d9a8de6088e98c2e638533d6f5bf (patch) | |
tree | c9770bf483655412a3144a07c219ddaed34ab064 /packages/sol-resolver | |
parent | 19064f8cbb21954108c4b8bd4a66879ddb240d7e (diff) | |
download | dexon-0x-contracts-0c12128f64f7d9a8de6088e98c2e638533d6f5bf.tar.gz dexon-0x-contracts-0c12128f64f7d9a8de6088e98c2e638533d6f5bf.tar.zst dexon-0x-contracts-0c12128f64f7d9a8de6088e98c2e638533d6f5bf.zip |
Temp CI
Diffstat (limited to 'packages/sol-resolver')
-rw-r--r-- | packages/sol-resolver/src/resolvers/npm_resolver.ts | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/packages/sol-resolver/src/resolvers/npm_resolver.ts b/packages/sol-resolver/src/resolvers/npm_resolver.ts index d9377989f..3c1d09557 100644 --- a/packages/sol-resolver/src/resolvers/npm_resolver.ts +++ b/packages/sol-resolver/src/resolvers/npm_resolver.ts @@ -8,11 +8,9 @@ import { Resolver } from './resolver'; export class NPMResolver extends Resolver { private readonly _packagePath: string; - private readonly _workspacePath: string; - constructor(packagePath: string, workspacePath: string = '/') { + constructor(packagePath: string) { super(); this._packagePath = packagePath; - this._workspacePath = workspacePath; } public resolveIfExists(importPath: string): ContractSource | undefined { if (!importPath.startsWith('/')) { @@ -25,11 +23,9 @@ export class NPMResolver extends Resolver { [packageName, ...other] = importPath.split('/'); } const pathWithinPackage = path.join(...other); - for ( - let currentPath = this._packagePath; - currentPath.includes(this._workspacePath); - currentPath = path.dirname(currentPath) - ) { + let currentPath = this._packagePath; + const ROOT_PATH = '/'; + while (currentPath !== ROOT_PATH) { const packagePath = _.isUndefined(packageScopeIfExists) ? packageName : path.join(packageScopeIfExists, packageName); @@ -38,6 +34,7 @@ export class NPMResolver extends Resolver { const fileContent = fs.readFileSync(lookupPath).toString(); return { source: fileContent, path: importPath, absolutePath: lookupPath }; } + currentPath = path.dirname(currentPath); } } return undefined; |