()
| 27 | ] |
| 28 | |
| 29 | async exec () { |
| 30 | if (this.npm.global) { |
| 31 | const er = new Error('`npm dedupe` does not work in global mode.') |
| 32 | er.code = 'EDEDUPEGLOBAL' |
| 33 | throw er |
| 34 | } |
| 35 | |
| 36 | const dryRun = this.npm.config.get('dry-run') |
| 37 | const where = this.npm.prefix |
| 38 | const Arborist = require('@npmcli/arborist') |
| 39 | const { policy: allowScriptsPolicy } = await resolveAllowScripts(this.npm) |
| 40 | const opts = { |
| 41 | ...this.npm.flatOptions, |
| 42 | path: where, |
| 43 | dryRun, |
| 44 | // Saving during dedupe would only update if one of your direct dependencies was also duplicated somewhere in your tree. |
| 45 | // It would be confusing if running this were to also update your package.json. |
| 46 | // In order to reduce potential confusion we set this to false. |
| 47 | save: false, |
| 48 | workspaces: this.workspaceNames, |
| 49 | allowScripts: allowScriptsPolicy, |
| 50 | } |
| 51 | const arb = new Arborist(opts) |
| 52 | await arb.dedupe(opts) |
| 53 | await reifyFinish(this.npm, arb) |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | module.exports = Dedupe |
nothing calls this directly
no test coverage detected