From fe40b52e9b7425f724e535e63877c25743e6c255 Mon Sep 17 00:00:00 2001 From: wusiquan <1781554387@qq.com> Date: Sun, 8 Dec 2019 11:52:33 +0800 Subject: [PATCH] feat: remove `if` check --- .../shared-utils/src/moduleResolver.ts | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/packages/@vuepress/shared-utils/src/moduleResolver.ts b/packages/@vuepress/shared-utils/src/moduleResolver.ts index 7ae69cfb98..cf38380fe7 100644 --- a/packages/@vuepress/shared-utils/src/moduleResolver.ts +++ b/packages/@vuepress/shared-utils/src/moduleResolver.ts @@ -212,19 +212,17 @@ class ModuleResolver { if (req.startsWith('@')) { const pkg = resolveScopePackage(req) - if (pkg) { - // special handling for default org. - if (this.org && pkg.org === this.org) { - shortcut = pkg.name.startsWith(`${this.type}-`) - ? pkg.name.slice(this.typePrefixLength) - : pkg.name - name = `${this.scopePrefix}${shortcut}` - } else { - shortcut = this.getShortcut(pkg.name) - name = `@${pkg.org}/${this.nonScopePrefix}${shortcut}` - } - shortcut = `@${pkg.org}/${shortcut}` + // special handling for default org. + if (this.org && pkg.org === this.org) { + shortcut = pkg.name.startsWith(`${this.type}-`) + ? pkg.name.slice(this.typePrefixLength) + : pkg.name + name = `${this.scopePrefix}${shortcut}` + } else { + shortcut = this.getShortcut(pkg.name) + name = `@${pkg.org}/${this.nonScopePrefix}${shortcut}` } + shortcut = `@${pkg.org}/${shortcut}` } else { shortcut = this.getShortcut(req) name = `${this.nonScopePrefix}${shortcut}`