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

Function unreviewedScriptsMessage

lib/utils/reify-output.js:235–270  ·  view source on GitHub ↗
(npm, unreviewedScripts)

Source from the content-addressed store, hash-verified

233}
234
235const unreviewedScriptsMessage = (npm, unreviewedScripts) => {
236 if (!unreviewedScripts.length) {
237 return
238 }
239
240 // Goes through log.warn so it respects --loglevel / --silent and lands
241 // on stderr like every other "FYI, here's something to know" message.
242 // stdout is reserved for things the user explicitly asked to see
243 // (npm ls, npm view).
244 const count = unreviewedScripts.length
245 const pkg = count === 1 ? 'package has' : 'packages have'
246 const header = `${count} ${pkg} install scripts not yet covered by allowScripts:`
247
248 const names = []
249 const lines = unreviewedScripts.map(({ node, scripts }) => {
250 const { name, version } = trustedDisplay(node)
251 /* istanbul ignore next: every test node has a name */
252 const display = name || '<unknown>'
253 names.push(display)
254 const ver = version ? `@${version}` : ''
255 const events = Object.entries(scripts)
256 .map(([event, cmd]) => `${event}: ${cmd}`)
257 .join('; ')
258 return ` ${display}${ver} (${events})`
259 })
260
261 log.warn(
262 'allow-scripts',
263 [
264 header,
265 ...lines,
266 '',
267 ...remediationLines(npm, names),
268 ].join('\n')
269 )
270}
271
272// `npm install-scripts` writes to a project package.json, which doesn't
273// exist for global installs (it throws EGLOBAL). For those, point users at

Callers 1

reifyOutputFunction · 0.85

Calls 4

trustedDisplayFunction · 0.85
remediationLinesFunction · 0.85
pushMethod · 0.80
warnMethod · 0.80

Tested by

no test coverage detected