aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-resolver/src/resolvers/npm_resolver.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2019-01-28 23:24:54 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2019-01-29 00:24:44 +0800
commit0c12128f64f7d9a8de6088e98c2e638533d6f5bf (patch)
treec9770bf483655412a3144a07c219ddaed34ab064 /packages/sol-resolver/src/resolvers/npm_resolver.ts
parent19064f8cbb21954108c4b8bd4a66879ddb240d7e (diff)
downloaddexon-0x-contracts-0c12128f64f7d9a8de6088e98c2e638533d6f5bf.tar
dexon-0x-contracts-0c12128f64f7d9a8de6088e98c2e638533d6f5bf.tar.gz
dexon-0x-contracts-0c12128f64f7d9a8de6088e98c2e638533d6f5bf.tar.bz2
dexon-0x-contracts-0c12128f64f7d9a8de6088e98c2e638533d6f5bf.tar.lz
dexon-0x-contracts-0c12128f64f7d9a8de6088e98c2e638533d6f5bf.tar.xz
dexon-0x-contracts-0c12128f64f7d9a8de6088e98c2e638533d6f5bf.tar.zst
dexon-0x-contracts-0c12128f64f7d9a8de6088e98c2e638533d6f5bf.zip
Temp CI
Diffstat (limited to 'packages/sol-resolver/src/resolvers/npm_resolver.ts')
-rw-r--r--packages/sol-resolver/src/resolvers/npm_resolver.ts13
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;