aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-12-03 20:40:06 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-12-03 20:40:06 +0800
commitc5e43f8da51296f3132b6baffd0c1ae5038e6f92 (patch)
tree42a90e4f14fb4e51d20b3829086ac4ed254bafa1 /packages
parent8a42cea978bc72abde12c91bd7fa07bef5439aa3 (diff)
downloaddexon-sol-tools-c5e43f8da51296f3132b6baffd0c1ae5038e6f92.tar
dexon-sol-tools-c5e43f8da51296f3132b6baffd0c1ae5038e6f92.tar.gz
dexon-sol-tools-c5e43f8da51296f3132b6baffd0c1ae5038e6f92.tar.bz2
dexon-sol-tools-c5e43f8da51296f3132b6baffd0c1ae5038e6f92.tar.lz
dexon-sol-tools-c5e43f8da51296f3132b6baffd0c1ae5038e6f92.tar.xz
dexon-sol-tools-c5e43f8da51296f3132b6baffd0c1ae5038e6f92.tar.zst
dexon-sol-tools-c5e43f8da51296f3132b6baffd0c1ae5038e6f92.zip
Use lodash _.startsWith
Diffstat (limited to 'packages')
-rw-r--r--packages/sol-resolver/src/resolvers/npm_resolver.ts8
1 files changed, 5 insertions, 3 deletions
diff --git a/packages/sol-resolver/src/resolvers/npm_resolver.ts b/packages/sol-resolver/src/resolvers/npm_resolver.ts
index 6c7ebdcd1..eeb2b5493 100644
--- a/packages/sol-resolver/src/resolvers/npm_resolver.ts
+++ b/packages/sol-resolver/src/resolvers/npm_resolver.ts
@@ -17,8 +17,8 @@ export class NPMResolver extends Resolver {
let packageName;
let packageScopeIfExists;
let other;
- if (importPath.startsWith('@')) {
- [packageScope, packageName, ...other] = importPath.split('/');
+ if (_.startsWith(importPath, '@')) {
+ [packageScopeIfExists, packageName, ...other] = importPath.split('/');
} else {
[packageName, ...other] = importPath.split('/');
}
@@ -26,7 +26,9 @@ export class NPMResolver extends Resolver {
let currentPath = this._packagePath;
const ROOT_PATH = '/';
while (currentPath !== ROOT_PATH) {
- const packagePath = _.isUndefined(packageScopeIfExists) ? packageName : path.join(packageScopeIfExists, packageName);
+ const packagePath = _.isUndefined(packageScopeIfExists)
+ ? packageName
+ : path.join(packageScopeIfExists, packageName);
const lookupPath = path.join(currentPath, 'node_modules', packagePath, pathWithinPackage);
if (fs.existsSync(lookupPath) && fs.lstatSync(lookupPath).isFile()) {
const fileContent = fs.readFileSync(lookupPath).toString();