fix: pnpm update --global --latest (#6671)

close #3779
This commit is contained in:
Zoltan Kochan
2023-06-14 07:41:16 +03:00
committed by GitHub
parent 04bee1e8bc
commit 0b830f947a
4 changed files with 25 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/plugin-commands-installation": patch
"pnpm": patch
---
`pnpm update --global --latest` should work [#3779](https://github.com/pnpm/pnpm/issues/3779).

View File

@@ -48,6 +48,7 @@ export type InstallDepsOptions = Pick<Config,
| 'global'
| 'globalPnpmfile'
| 'hooks'
| 'ignoreCurrentPrefs'
| 'ignorePnpmfile'
| 'ignoreScripts'
| 'linkWorkspacePackages'

View File

@@ -267,6 +267,7 @@ async function update (
...opts,
allowNew: false,
depth,
ignoreCurrentPrefs: false,
includeDirect,
include,
update: true,

View File

@@ -86,3 +86,20 @@ test('run lifecycle events of global packages in correct working directory', asy
expect(await exists(path.join(global, `pnpm/global/${LAYOUT_VERSION}/node_modules/@pnpm.e2e/postinstall-calls-pnpm/created-by-postinstall`))).toBeTruthy()
})
test('global update to latest', async () => {
prepare()
const global = path.resolve('..', 'global')
const pnpmHome = path.join(global, 'pnpm')
fs.mkdirSync(global)
const env = { [PATH_NAME]: pnpmHome, PNPM_HOME: pnpmHome, XDG_DATA_HOME: global }
await execPnpm(['install', '--global', 'is-positive@1'], { env })
await execPnpm(['update', '--global', '--latest'], { env })
const globalPrefix = path.join(global, `pnpm/global/${LAYOUT_VERSION}`)
const { default: isPositive } = await import(path.join(globalPrefix, 'node_modules/is-positive/package.json'))
expect(isPositive.version).toBe('3.1.0')
})