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

Function parsePositional

lib/utils/allow-scripts-cmd.js:21–37  ·  view source on GitHub ↗
(arg)

Source from the content-addressed store, hash-verified

19// semver. npm-package-arg handles dotted and scoped names; fall back to the
20// raw string as the name if it can't be parsed.
21const parsePositional = (arg) => {
22 let parsed
23 try {
24 parsed = npa(arg)
25 } catch {
26 return { name: arg, range: null }
27 }
28 const name = parsed.name || arg
29 if (parsed.type === 'version' || parsed.type === 'range') {
30 const spec = parsed.fetchSpec
31 const range = (!spec || spec === '*' || parsed.rawSpec === '' || parsed.rawSpec === '*')
32 ? null
33 : spec
34 return { name, range }
35 }
36 return { name, range: null }
37}
38
39// Shared implementation for `npm approve-scripts`, `npm deny-scripts`, and the `npm install-scripts` namespace.
40// `npm install-scripts` dispatches to `runMode('approve' | 'deny' | 'list', ...)`.

Callers 1

findNodesForArgsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected