From 0c12128f64f7d9a8de6088e98c2e638533d6f5bf Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 28 Jan 2019 16:24:54 +0100 Subject: Temp CI --- packages/sol-resolver/src/resolvers/npm_resolver.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'packages/sol-resolver') 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; -- cgit