Skip to content

Commit

Permalink
refactor: call installDeps directly in dedupe command handler (#6403)
Browse files Browse the repository at this point in the history
* refactor: call installDeps directly in dedupe command handler

This allows the dedupe command to pass options to the `installDeps`
function that aren't available on the pnpm install command line or
config interface.

This better matches the setup in the `add` and `update` command
handlers, which also call `installDeps` directly. The previous setup
mimicked the `prune` command. Keeping the dedupe and install commands as
similar as possible was the original goal of having the dedupe command
reuse the install command handler, but this may not be necessary due to
how small the install command handler is. Small logic related to what
dependency fields to use was copied over.

There should be no expected behavior changes in this commit. The
`frozenLockfile` setting was not necessary to copy the `dedupe` option
skips all frozen lockfile logic.

* break: remove unused dedupe argument on install command handler

This becomes unnecessary now that the dedupe command handler no longer
calls the install command handler directly.
  • Loading branch information
gluxon committed Apr 16, 2023
1 parent d43ccc4 commit 8e7a86d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/fast-icons-retire.md
@@ -0,0 +1,5 @@
---
"@pnpm/plugin-commands-installation": patch
---

Internal refactor to call installDeps directly in the pnpm dedupe command handler. No behavior changes are expected with this refactor.
5 changes: 5 additions & 0 deletions .changeset/sixty-scissors-enjoy.md
@@ -0,0 +1,5 @@
---
"@pnpm/plugin-commands-installation": major
---

Remove the `dedupe` option from `InstallCommandOptions`. This was not intentionally part of the public install command's API when it was added.
18 changes: 12 additions & 6 deletions pkg-manager/plugin-commands-installation/src/dedupe.ts
@@ -1,7 +1,8 @@
import { docsUrl } from '@pnpm/cli-utils'
import { UNIVERSAL_OPTIONS } from '@pnpm/common-cli-options-help'
import renderHelp from 'render-help'
import * as install from './install'
import { type InstallCommandOptions } from './install'
import { installDeps } from './installDeps'

export const rcOptionsTypes = cliOptionsTypes

Expand All @@ -27,11 +28,16 @@ export function help () {
})
}

export async function handler (
opts: install.InstallCommandOptions
) {
return install.handler({
export async function handler (opts: InstallCommandOptions) {
const include = {
dependencies: opts.production !== false,
devDependencies: opts.dev !== false,
optionalDependencies: opts.optional !== false,
}
return installDeps({
...opts,
dedupe: true,
})
include,
includeDirect: include,
}, [])
}
1 change: 0 additions & 1 deletion pkg-manager/plugin-commands-installation/src/install.ts
Expand Up @@ -296,7 +296,6 @@ export type InstallCommandOptions = Pick<Config,
pruneDirectDependencies?: boolean
pruneStore?: boolean
recursive?: boolean
dedupe?: boolean
saveLockfile?: boolean
workspace?: boolean
includeOnlyPackageFiles?: boolean
Expand Down

0 comments on commit 8e7a86d

Please sign in to comment.