Skip to content

Commit a2d700b

Browse files
committed
1 parent 18ddc57 commit a2d700b

File tree

4 files changed

+50
-12
lines changed

4 files changed

+50
-12
lines changed

node_modules/npm-package-arg/lib/npa.js

+40-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const semver = require('semver')
99
const path = global.FAKE_WINDOWS ? require('path').win32 : require('path')
1010
const validatePackageName = require('validate-npm-package-name')
1111
const { homedir } = require('os')
12+
const log = require('proc-log')
1213

1314
const isWindows = process.platform === 'win32' || global.FAKE_WINDOWS
1415
const hasSlashes = isWindows ? /\\|[/]/ : /[/]/
@@ -120,6 +121,7 @@ function Result (opts) {
120121
}
121122
this.gitRange = opts.gitRange
122123
this.gitCommittish = opts.gitCommittish
124+
this.gitSubdir = opts.gitSubdir
123125
this.hosted = opts.hosted
124126
}
125127

@@ -155,11 +157,45 @@ Result.prototype.toJSON = function () {
155157
}
156158

157159
function setGitCommittish (res, committish) {
158-
if (committish != null && committish.length >= 7 && committish.slice(0, 7) === 'semver:') {
159-
res.gitRange = decodeURIComponent(committish.slice(7))
160+
if (!committish) {
160161
res.gitCommittish = null
161-
} else {
162-
res.gitCommittish = committish === '' ? null : committish
162+
return res
163+
}
164+
165+
// for each :: separated item:
166+
for (const part of committish.split('::')) {
167+
// if the item has no : the n it is a commit-ish
168+
if (!part.includes(':')) {
169+
if (res.gitRange) {
170+
throw new Error('cannot override existing semver range with a committish')
171+
}
172+
if (res.gitCommittish) {
173+
throw new Error('cannot override existing committish with a second committish')
174+
}
175+
res.gitCommittish = part
176+
continue
177+
}
178+
// split on name:value
179+
const [name, value] = part.split(':')
180+
// if name is semver do semver lookup of ref or tag
181+
if (name === 'semver') {
182+
if (res.gitCommittish) {
183+
throw new Error('cannot override existing committish with a semver range')
184+
}
185+
if (res.gitRange) {
186+
throw new Error('cannot override existing semver range with a second semver range')
187+
}
188+
res.gitRange = decodeURIComponent(value)
189+
continue
190+
}
191+
if (name === 'path') {
192+
if (res.gitSubdir) {
193+
throw new Error('cannot override existing path with a second path')
194+
}
195+
res.gitSubdir = `/${value}`
196+
continue
197+
}
198+
log.warn('npm-package-arg', `ignoring unknown key "${name}"`)
163199
}
164200

165201
return res

node_modules/npm-package-arg/package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "npm-package-arg",
3-
"version": "9.0.2",
3+
"version": "9.1.0",
44
"description": "Parse the things that can be arguments to `npm install`",
55
"main": "./lib/npa.js",
66
"directories": {
@@ -12,12 +12,13 @@
1212
],
1313
"dependencies": {
1414
"hosted-git-info": "^5.0.0",
15+
"proc-log": "^2.0.1",
1516
"semver": "^7.3.5",
1617
"validate-npm-package-name": "^4.0.0"
1718
},
1819
"devDependencies": {
1920
"@npmcli/eslint-config": "^3.0.1",
20-
"@npmcli/template-oss": "3.2.1",
21+
"@npmcli/template-oss": "3.5.0",
2122
"tap": "^16.0.1"
2223
},
2324
"scripts": {
@@ -52,6 +53,6 @@
5253
},
5354
"templateOSS": {
5455
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
55-
"version": "3.2.1"
56+
"version": "3.5.0"
5657
}
5758
}

package-lock.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
"nopt": "^5.0.0",
133133
"npm-audit-report": "^3.0.0",
134134
"npm-install-checks": "^5.0.0",
135-
"npm-package-arg": "^9.0.2",
135+
"npm-package-arg": "^9.1.0",
136136
"npm-pick-manifest": "^7.0.1",
137137
"npm-profile": "^6.1.0",
138138
"npm-registry-fetch": "^13.1.1",
@@ -5131,12 +5131,13 @@
51315131
"license": "ISC"
51325132
},
51335133
"node_modules/npm-package-arg": {
5134-
"version": "9.0.2",
5135-
"resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-9.0.2.tgz",
5136-
"integrity": "sha512-v/miORuX8cndiOheW8p2moNuPJ7QhcFh9WGlTorruG8hXSA23vMTEp5hTCmDxic0nD8KHhj/NQgFuySD3GYY3g==",
5134+
"version": "9.1.0",
5135+
"resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-9.1.0.tgz",
5136+
"integrity": "sha512-4J0GL+u2Nh6OnhvUKXRr2ZMG4lR8qtLp+kv7UiV00Y+nGiSxtttCyIRHCt5L5BNkXQld/RceYItau3MDOoGiBw==",
51375137
"inBundle": true,
51385138
"dependencies": {
51395139
"hosted-git-info": "^5.0.0",
5140+
"proc-log": "^2.0.1",
51405141
"semver": "^7.3.5",
51415142
"validate-npm-package-name": "^4.0.0"
51425143
},

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
"nopt": "^5.0.0",
101101
"npm-audit-report": "^3.0.0",
102102
"npm-install-checks": "^5.0.0",
103-
"npm-package-arg": "^9.0.2",
103+
"npm-package-arg": "^9.1.0",
104104
"npm-pick-manifest": "^7.0.1",
105105
"npm-profile": "^6.1.0",
106106
"npm-registry-fetch": "^13.1.1",

0 commit comments

Comments
 (0)