From c5e43f8da51296f3132b6baffd0c1ae5038e6f92 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 3 Dec 2018 13:40:06 +0100 Subject: Use lodash _.startsWith --- packages/sol-resolver/src/resolvers/npm_resolver.ts | 8 +++++--- 1 file 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(); -- cgit v1.2.3