diff --git a/packages/pnpm/src/cmd/install.ts b/packages/pnpm/src/cmd/install.ts index d7144fd156..de4119cb65 100644 --- a/packages/pnpm/src/cmd/install.ts +++ b/packages/pnpm/src/cmd/install.ts @@ -9,6 +9,11 @@ import requireHooks from '../requireHooks' import {PnpmOptions} from '../types' import {recursive} from './recursive' +const OVERWRITE_UPDATE_OPTIONS = { + allowNew: true, + update: false, +} + /** * Perform installation. * @example @@ -16,7 +21,9 @@ import {recursive} from './recursive' */ export default async function installCmd ( input: string[], - opts: PnpmOptions, + opts: PnpmOptions & { + allowNew?: boolean, + }, ) { // `pnpm install ""` is going to be just `pnpm install` input = input.filter(Boolean) @@ -53,6 +60,7 @@ export default async function installCmd ( const allWorkspacePkgs = await findWorkspacePackages(opts.workspacePrefix) await recursive(allWorkspacePkgs, [], { ...opts, + ...OVERWRITE_UPDATE_OPTIONS, filterByEntryDirectory: prefix, inputForEntryDirectory: input, }, 'install', 'install') diff --git a/packages/pnpm/src/cmd/recursive/index.ts b/packages/pnpm/src/cmd/recursive/index.ts index 4eacb898c2..858a6f8a79 100644 --- a/packages/pnpm/src/cmd/recursive/index.ts +++ b/packages/pnpm/src/cmd/recursive/index.ts @@ -80,6 +80,7 @@ export async function recursive ( allPkgs: Array<{path: string, manifest: PackageJson}>, input: string[], opts: PnpmOptions & { + allowNew?: boolean, filterByEntryDirectory?: string, inputForEntryDirectory?: string[], }, diff --git a/packages/pnpm/src/cmd/update.ts b/packages/pnpm/src/cmd/update.ts index 8356fa08a0..86056d51df 100644 --- a/packages/pnpm/src/cmd/update.ts +++ b/packages/pnpm/src/cmd/update.ts @@ -1,26 +1,9 @@ -import { - install, - installPkgs, -} from 'supi' -import createStoreController from '../createStoreController' -import requireHooks from '../requireHooks' import {PnpmOptions} from '../types' +import installCmd from './install' export default async function ( input: string[], opts: PnpmOptions, ) { - const store = await createStoreController(opts) - const updateOpts = Object.assign(opts, { - allowNew: false, - hooks: !opts.ignorePnpmfile && requireHooks(opts.prefix, opts), - store: store.path, - storeController: store.ctrl, - update: true, - }) - - if (!input || !input.length) { - return install(updateOpts) - } - return installPkgs(input, updateOpts) + return installCmd(input, {...opts, update: true, allowNew: false}) } diff --git a/packages/pnpm/test/monorepo/index.ts b/packages/pnpm/test/monorepo/index.ts index 5a74644fd9..19aa586717 100644 --- a/packages/pnpm/test/monorepo/index.ts +++ b/packages/pnpm/test/monorepo/index.ts @@ -164,4 +164,11 @@ test('linking a package inside a monorepo with --link-workspace-packages', async const shr = await projects['project-1'].loadShrinkwrap() t.equal(shr.optionalDependencies['is-positive'], '1.0.0') } + + await execPnpm('update', 'is-negative@2.0.0') + + { + const shr = await projects['project-1'].loadShrinkwrap() + t.equal(shr.devDependencies['is-negative'], '2.0.0') + } })