summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/npm-package-arg/npa.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/npm-package-arg/npa.js')
-rw-r--r--deps/npm/node_modules/npm-package-arg/npa.js20
1 files changed, 19 insertions, 1 deletions
diff --git a/deps/npm/node_modules/npm-package-arg/npa.js b/deps/npm/node_modules/npm-package-arg/npa.js
index dc885b1ff1..4d56237a57 100644
--- a/deps/npm/node_modules/npm-package-arg/npa.js
+++ b/deps/npm/node_modules/npm-package-arg/npa.js
@@ -62,6 +62,8 @@ function resolve (name, spec, where, arg) {
if (spec && (isFilespec.test(spec) || /^file:/i.test(spec))) {
return fromFile(res, where)
+ } else if (spec && /^npm:/i.test(spec)) {
+ return fromAlias(res, where)
}
if (!HostedGit) HostedGit = require('hosted-git-info')
const hosted = HostedGit.fromUrl(spec, {noGitPlus: true, noCommittish: true})
@@ -231,8 +233,8 @@ function fromURL (res) {
res.type = 'git'
const match = urlparse.protocol === 'git+ssh:' && matchGitScp(res.rawSpec)
if (match) {
+ setGitCommittish(res, match.gitCommittish)
res.fetchSpec = match.fetchSpec
- res.gitCommittish = match.gitCommittish
} else {
setGitCommittish(res, urlparse.hash != null ? urlparse.hash.slice(1) : '')
urlparse.protocol = urlparse.protocol.replace(/^git[+]/, '')
@@ -253,6 +255,22 @@ function fromURL (res) {
return res
}
+function fromAlias (res, where) {
+ const subSpec = npa(res.rawSpec.substr(4), where)
+ if (subSpec.type === 'alias') {
+ throw new Error('nested aliases not supported')
+ }
+ if (!subSpec.registry) {
+ throw new Error('aliases only work for registry deps')
+ }
+ res.subSpec = subSpec
+ res.registry = true
+ res.type = 'alias'
+ res.saveSpec = null
+ res.fetchSpec = null
+ return res
+}
+
function fromRegistry (res) {
res.registry = true
const spec = res.rawSpec === '' ? 'latest' : res.rawSpec