2021-11-04 20:42:47 +00:00
|
|
|
const reifyFinish = require('../utils/reify-finish.js')
|
|
|
|
const ArboristWorkspaceCmd = require('../arborist-cmd.js')
|
2024-04-30 23:53:22 -07:00
|
|
|
|
|
|
|
// prune extraneous packages
|
2021-05-20 15:54:50 -04:00
|
|
|
class Prune extends ArboristWorkspaceCmd {
|
2021-11-18 20:58:02 +00:00
|
|
|
static description = 'Remove extraneous packages'
|
|
|
|
static name = 'prune'
|
2022-03-17 20:22:31 +00:00
|
|
|
static params = [
|
|
|
|
'omit',
|
2023-10-13 06:55:37 -07:00
|
|
|
'include',
|
2022-03-17 20:22:31 +00:00
|
|
|
'dry-run',
|
|
|
|
'json',
|
|
|
|
'foreground-scripts',
|
|
|
|
'ignore-scripts',
|
|
|
|
...super.params,
|
|
|
|
]
|
|
|
|
|
2021-11-18 20:58:02 +00:00
|
|
|
static usage = ['[[<@scope>/]<pkg>...]']
|
2020-10-02 17:52:19 -04:00
|
|
|
|
2021-11-04 20:42:47 +00:00
|
|
|
async exec () {
|
2021-03-04 17:40:28 -05:00
|
|
|
const where = this.npm.prefix
|
2023-05-07 03:37:34 -07:00
|
|
|
const Arborist = require('@npmcli/arborist')
|
2021-03-24 17:25:32 -04:00
|
|
|
const opts = {
|
2021-03-04 17:40:28 -05:00
|
|
|
...this.npm.flatOptions,
|
|
|
|
path: where,
|
2021-06-17 18:59:38 +00:00
|
|
|
workspaces: this.workspaceNames,
|
2021-03-24 17:25:32 -04:00
|
|
|
}
|
|
|
|
const arb = new Arborist(opts)
|
|
|
|
await arb.prune(opts)
|
2021-03-04 17:40:28 -05:00
|
|
|
await reifyFinish(this.npm, arb)
|
|
|
|
}
|
|
|
|
}
|
2024-04-30 23:53:22 -07:00
|
|
|
|
2021-03-04 17:40:28 -05:00
|
|
|
module.exports = Prune
|