fix(remove): read the production/optional/dev options (#3541)

This commit is contained in:
Zoltan Kochan
2021-06-17 01:58:26 +03:00
committed by GitHub
parent 7613675195
commit 72c0dd7be4
2 changed files with 16 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/plugin-commands-installation": patch
---
The remove command should read the production/optional/dev options.

View File

@@ -128,12 +128,15 @@ export async function handler (
| 'allProjects'
| 'bail'
| 'bin'
| 'dev'
| 'engineStrict'
| 'globalPnpmfile'
| 'ignorePnpmfile'
| 'lockfileDir'
| 'linkWorkspacePackages'
| 'lockfileDir'
| 'optional'
| 'pnpmfile'
| 'production'
| 'rawLocalConfig'
| 'registries'
| 'saveDev'
@@ -147,14 +150,20 @@ export async function handler (
params: string[]
) {
if (params.length === 0) throw new PnpmError('MUST_REMOVE_SOMETHING', 'At least one dependency name should be specified for removal')
const include = {
dependencies: opts.production !== false,
devDependencies: opts.dev !== false,
optionalDependencies: opts.optional !== false,
}
if (opts.recursive && (opts.allProjects != null) && (opts.selectedProjectsGraph != null) && opts.workspaceDir) {
await recursive(opts.allProjects, params, { ...opts, selectedProjectsGraph: opts.selectedProjectsGraph, workspaceDir: opts.workspaceDir }, 'remove')
await recursive(opts.allProjects, params, { ...opts, include, selectedProjectsGraph: opts.selectedProjectsGraph, workspaceDir: opts.workspaceDir }, 'remove')
return
}
const store = await createOrConnectStoreController(opts)
const removeOpts = Object.assign(opts, {
storeController: store.ctrl,
storeDir: store.dir,
include,
})
if (!opts.ignorePnpmfile) {
removeOpts['hooks'] = requireHooks(opts.lockfileDir ?? opts.dir, opts)