| 103 | } |
| 104 | |
| 105 | runPending (unreviewed) { |
| 106 | if (this.npm.flatOptions.json) { |
| 107 | output.buffer({ allowScripts: this.pendingSummary(unreviewed) }) |
| 108 | return |
| 109 | } |
| 110 | if (unreviewed.length === 0) { |
| 111 | output.standard('No packages with unreviewed install scripts.') |
| 112 | return |
| 113 | } |
| 114 | const count = unreviewed.length |
| 115 | const has = count === 1 ? 'has' : 'have' |
| 116 | const pkg = count === 1 ? 'package' : 'packages' |
| 117 | output.standard( |
| 118 | `${count} ${pkg} ${has} install scripts not yet covered by allowScripts:` |
| 119 | ) |
| 120 | for (const { node, scripts } of unreviewed) { |
| 121 | const { name, version } = trustedDisplay(node) |
| 122 | /* istanbul ignore next: every test node has a name */ |
| 123 | const display = name || '<unknown>' |
| 124 | const ver = version ? `@${version}` : '' |
| 125 | const events = Object.entries(scripts) |
| 126 | .map(([event, cmd]) => `${event}: ${cmd}`) |
| 127 | .join('; ') |
| 128 | output.standard(` ${display}${ver} (${events})`) |
| 129 | } |
| 130 | output.standard('') |
| 131 | output.standard( |
| 132 | 'Run `npm approve-scripts <pkg>` to allow, or `npm deny-scripts <pkg>` to deny.' |
| 133 | ) |
| 134 | } |
| 135 | |
| 136 | // Build the same `{ name, changes }` shape printSummary uses for writes, |
| 137 | // but tag every entry as `pending` since nothing is written. Names and |