(unreviewed, { remediation } = {})
| 79 | // caller-specific guidance appended after the package list (npm install vs |
| 80 | // npm exec have different remediation commands). |
| 81 | const strictAllowScriptsError = (unreviewed, { remediation } = {}) => { |
| 82 | const lines = unreviewed.map(({ node, scripts }) => { |
| 83 | const events = Object.entries(scripts) |
| 84 | .map(([event, body]) => `${event}: ${body}`) |
| 85 | .join('; ') |
| 86 | const name = node.package?.name || node.name |
| 87 | const version = node.package?.version || '' |
| 88 | const label = version ? `${name}@${version}` : name |
| 89 | return ` ${label} (${events})` |
| 90 | }).join('\n') |
| 91 | |
| 92 | return Object.assign( |
| 93 | new Error( |
| 94 | `--strict-allow-scripts: ${unreviewed.length} package(s) have install ` + |
| 95 | `scripts not covered by allowScripts:\n${lines}\n${remediation}` |
| 96 | ), |
| 97 | { code: 'ESTRICTALLOWSCRIPTS' } |
| 98 | ) |
| 99 | } |
| 100 | |
| 101 | module.exports = { collectUnreviewedScripts, strictAllowScriptsError } |
no outgoing calls
no test coverage detected