xref: /third_party/node/deps/npm/lib/commands/prune.js (revision 1cb0ef41)
1// prune extraneous packages
2const reifyFinish = require('../utils/reify-finish.js')
3
4const ArboristWorkspaceCmd = require('../arborist-cmd.js')
5class Prune extends ArboristWorkspaceCmd {
6  static description = 'Remove extraneous packages'
7  static name = 'prune'
8  static params = [
9    'omit',
10    'include',
11    'dry-run',
12    'json',
13    'foreground-scripts',
14    'ignore-scripts',
15    ...super.params,
16  ]
17
18  static usage = ['[[<@scope>/]<pkg>...]']
19
20  async exec () {
21    const where = this.npm.prefix
22    const Arborist = require('@npmcli/arborist')
23    const opts = {
24      ...this.npm.flatOptions,
25      path: where,
26      workspaces: this.workspaceNames,
27    }
28    const arb = new Arborist(opts)
29    await arb.prune(opts)
30    await reifyFinish(this.npm, arb)
31  }
32}
33module.exports = Prune
34