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

Function reifyOutput

deps/npm/lib/utils/reify-output.js:21–136  ·  view source on GitHub ↗
(npm, arb, extras = {})

Source from the content-addressed store, hash-verified

19const { configSetAllowScripts } = require('./allow-scripts-remediation.js')
20
21const reifyOutput = (npm, arb, extras = {}) => {
22 const { diff, actualTree } = arb
23 const unreviewedScripts = extras.unreviewedScripts || []
24
25 // note: fails and crashes if we're running audit fix and there was an error which is a good thing, because there's no point printing all this other stuff in that case!
26 const auditReport = auditError(npm, arb.auditReport) ? null : arb.auditReport
27
28 // don't print any info in --silent mode, but we still need to set the exitCode properly from the audit report, if we have one.
29 if (npm.silent) {
30 getAuditReport(npm, auditReport)
31 return
32 }
33
34 const summary = {
35 add: [],
36 added: 0,
37 // audit gets added later
38 audited: auditReport && !auditReport.error ? actualTree.inventory.size : 0,
39 change: [],
40 changed: 0,
41 funding: 0,
42 remove: [],
43 removed: 0,
44 }
45
46 if (diff) {
47 const showDiff = npm.config.get('dry-run') || npm.config.get('long')
48 const chalk = npm.chalk
49
50 depth({
51 tree: diff,
52 visit: d => {
53 switch (d.action) {
54 case 'REMOVE':
55 if (showDiff) {
56 output.standard(`${chalk.blue('remove')} ${d.actual.name} ${d.actual.package.version}`)
57 }
58 summary.removed++
59 summary.remove.push({
60 name: d.actual.name,
61 version: d.actual.package.version,
62 path: d.actual.path,
63 })
64 break
65 case 'ADD':
66 if (showDiff) {
67 output.standard(`${chalk.green('add')} ${d.ideal.name} ${d.ideal.package.version}`)
68 }
69 if (actualTree.inventory.has(d.ideal)) {
70 summary.added++
71 summary.add.push({
72 name: d.ideal.name,
73 version: d.ideal.package.version,
74 path: d.ideal.path,
75 })
76 }
77 break
78 case 'CHANGE':

Callers 4

reifyFinishFunction · 0.85
mockReifyFunction · 0.85
mockReifyWithExtrasFunction · 0.85
reify-output.jsFile · 0.85

Calls 15

getAuditReportFunction · 0.85
packagesChangedMessageFunction · 0.85
packagesFundingMessageFunction · 0.85
printAuditReportFunction · 0.85
unreviewedScriptsMessageFunction · 0.85
blueMethod · 0.80
auditErrorFunction · 0.70
getMethod · 0.65
hasMethod · 0.65
mapMethod · 0.65
depthFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…