mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-05 22:47:50 -04:00
fix: update should try to resolve packages from the workspace
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -80,6 +80,7 @@ export async function recursive (
|
||||
allPkgs: Array<{path: string, manifest: PackageJson}>,
|
||||
input: string[],
|
||||
opts: PnpmOptions & {
|
||||
allowNew?: boolean,
|
||||
filterByEntryDirectory?: string,
|
||||
inputForEntryDirectory?: string[],
|
||||
},
|
||||
|
||||
@@ -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})
|
||||
}
|
||||
|
||||
@@ -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')
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user