MCPcopy Create free account
hub / github.com/npm/cli / isExactVersionDisjunction

Function isExactVersionDisjunction

workspaces/arborist/lib/script-allowed.js:264–277  ·  view source on GitHub ↗
(rangeSpec)

Source from the content-addressed store, hash-verified

262// True if `rangeSpec` is one or more exact versions joined by `||`. Anything
263// containing comparator operators (^, ~, >=, <, *) returns false.
264const isExactVersionDisjunction = (rangeSpec) => {
265 /* istanbul ignore next: caller always passes parsed.fetchSpec, which
266 npa guarantees to be a non-empty string for range specs. */
267 if (typeof rangeSpec !== 'string' || rangeSpec.trim() === '') {
268 return false
269 }
270 const parts = rangeSpec.split('||').map(p => p.trim())
271 /* istanbul ignore next: String.prototype.split always returns at least
272 one element; defensive guard only. */
273 if (parts.length === 0) {
274 return false
275 }
276 return parts.every(p => p !== '' && semver.valid(p) !== null)
277}
278
279const matchGit = (node, parsed) => {
280 if (!node.resolved || !node.resolved.startsWith('git')) {

Callers 2

validatePolicyFunction · 0.85
matchRegistryFunction · 0.85

Calls 1

validMethod · 0.45

Tested by

no test coverage detected