MCPcopy Index your code
hub / github.com/nodejs/node / parsePositional

Function parsePositional

deps/npm/lib/utils/allow-scripts-cmd.js:19–35  ·  view source on GitHub ↗
(arg)

Source from the content-addressed store, hash-verified

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

Callers 1

findNodesForArgsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…