11cb0ef41Sopenharmony_ci// prune extraneous packages
21cb0ef41Sopenharmony_ciconst reifyFinish = require('../utils/reify-finish.js')
31cb0ef41Sopenharmony_ci
41cb0ef41Sopenharmony_ciconst ArboristWorkspaceCmd = require('../arborist-cmd.js')
51cb0ef41Sopenharmony_ciclass Prune extends ArboristWorkspaceCmd {
61cb0ef41Sopenharmony_ci  static description = 'Remove extraneous packages'
71cb0ef41Sopenharmony_ci  static name = 'prune'
81cb0ef41Sopenharmony_ci  static params = [
91cb0ef41Sopenharmony_ci    'omit',
101cb0ef41Sopenharmony_ci    'include',
111cb0ef41Sopenharmony_ci    'dry-run',
121cb0ef41Sopenharmony_ci    'json',
131cb0ef41Sopenharmony_ci    'foreground-scripts',
141cb0ef41Sopenharmony_ci    'ignore-scripts',
151cb0ef41Sopenharmony_ci    ...super.params,
161cb0ef41Sopenharmony_ci  ]
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_ci  static usage = ['[[<@scope>/]<pkg>...]']
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_ci  async exec () {
211cb0ef41Sopenharmony_ci    const where = this.npm.prefix
221cb0ef41Sopenharmony_ci    const Arborist = require('@npmcli/arborist')
231cb0ef41Sopenharmony_ci    const opts = {
241cb0ef41Sopenharmony_ci      ...this.npm.flatOptions,
251cb0ef41Sopenharmony_ci      path: where,
261cb0ef41Sopenharmony_ci      workspaces: this.workspaceNames,
271cb0ef41Sopenharmony_ci    }
281cb0ef41Sopenharmony_ci    const arb = new Arborist(opts)
291cb0ef41Sopenharmony_ci    await arb.prune(opts)
301cb0ef41Sopenharmony_ci    await reifyFinish(this.npm, arb)
311cb0ef41Sopenharmony_ci  }
321cb0ef41Sopenharmony_ci}
331cb0ef41Sopenharmony_cimodule.exports = Prune
34