mirror of
https://github.com/nodejs/node.git
synced 2025-05-17 23:31:07 +00:00

PR-URL: https://github.com/nodejs/node/pull/40726 Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Voltrex <mohammadkeyvanzade94@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Rich Trott <rtrott@gmail.com>
41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
// prune extraneous packages
|
|
const Arborist = require('@npmcli/arborist')
|
|
const reifyFinish = require('../utils/reify-finish.js')
|
|
|
|
const ArboristWorkspaceCmd = require('../arborist-cmd.js')
|
|
class Prune extends ArboristWorkspaceCmd {
|
|
/* istanbul ignore next - see test/lib/load-all-commands.js */
|
|
static get description () {
|
|
return 'Remove extraneous packages'
|
|
}
|
|
|
|
/* istanbul ignore next - see test/lib/load-all-commands.js */
|
|
static get name () {
|
|
return 'prune'
|
|
}
|
|
|
|
/* istanbul ignore next - see test/lib/load-all-commands.js */
|
|
static get params () {
|
|
return ['omit', 'dry-run', 'json', ...super.params]
|
|
}
|
|
|
|
/* istanbul ignore next - see test/lib/load-all-commands.js */
|
|
static get usage () {
|
|
return ['[[<@scope>/]<pkg>...]']
|
|
}
|
|
|
|
async exec () {
|
|
const where = this.npm.prefix
|
|
const opts = {
|
|
...this.npm.flatOptions,
|
|
path: where,
|
|
log: this.npm.log,
|
|
workspaces: this.workspaceNames,
|
|
}
|
|
const arb = new Arborist(opts)
|
|
await arb.prune(opts)
|
|
await reifyFinish(this.npm, arb)
|
|
}
|
|
}
|
|
module.exports = Prune
|