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

Method groupByPackage

lib/utils/allow-scripts-cmd.js:255–273  ·  view source on GitHub ↗
(nodes)

Source from the content-addressed store, hash-verified

253 }
254
255 groupByPackage (nodes) {
256 const groups = {}
257 for (const node of nodes) {
258 const key = nameKeyFor(node)
259 /* istanbul ignore if: callers prefilter via inBundle and trustedDisplay so untrusted nodes don't reach here */
260 if (!key) {
261 log.warn(
262 this.logTitle,
263 `skipping ${node.name || '<unknown>'}: no trusted identity for policy key`
264 )
265 continue
266 }
267 if (!groups[key]) {
268 groups[key] = []
269 }
270 groups[key].push(node)
271 }
272 return groups
273 }
274
275 async writePolicyChanges (groups) {
276 const pin = this.npm.config.get('allow-scripts-pin') !== false

Callers 2

runAllMethod · 0.95
runPositionalMethod · 0.95

Calls 3

nameKeyForFunction · 0.85
warnMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected