fix: clean pnpm workspace state during ci (#11368)

Co-authored-by: cyphercodes <cyphercodes@users.noreply.github.com>
This commit is contained in:
Rayan Salhab
2026-04-28 02:23:38 +03:00
committed by Zoltan Kochan
parent bf4214eb55
commit 32eae3112f
3 changed files with 8 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
"pnpm": patch
---
Remove pnpm's workspace state file when cleaning node_modules so `pnpm ci` performs a fresh install after the clean step.

View File

@@ -103,7 +103,7 @@ async function cleanProjectDir (opts: { modulesDir: string, removeLockfile?: boo
}
}
const PNPM_HIDDEN_ENTRIES = new Set(['.bin', '.modules.yaml', '.pnpm'])
const PNPM_HIDDEN_ENTRIES = new Set(['.bin', '.modules.yaml', '.pnpm', '.pnpm-workspace-state-v1.json'])
async function hasContentsToRemove (modulesDir: string): Promise<boolean> {
let items: string[]

View File

@@ -20,6 +20,7 @@ test('pnpm clean removes pnpm entries and packages but preserves non-pnpm hidden
fs.mkdirSync('node_modules/.pnpm', { recursive: true })
fs.mkdirSync('node_modules/.bin')
fs.writeFileSync('node_modules/.modules.yaml', 'storeDir: /tmp/store')
fs.writeFileSync('node_modules/.pnpm-workspace-state-v1.json', '{}')
fs.mkdirSync('node_modules/.cache')
fs.writeFileSync('node_modules/.cache/some-file', 'cached')
fs.mkdirSync('node_modules/lodash')
@@ -34,6 +35,7 @@ test('pnpm clean removes pnpm entries and packages but preserves non-pnpm hidden
expect(fs.existsSync('node_modules/.pnpm')).toBe(false)
expect(fs.existsSync('node_modules/.bin')).toBe(false)
expect(fs.existsSync('node_modules/.modules.yaml')).toBe(false)
expect(fs.existsSync('node_modules/.pnpm-workspace-state-v1.json')).toBe(false)
// Regular packages should be removed
expect(fs.existsSync('node_modules/lodash')).toBe(false)