diff --git a/pnpm/.changeset/clean-ci-workspace-state.md b/pnpm/.changeset/clean-ci-workspace-state.md new file mode 100644 index 0000000000..6e23ce8462 --- /dev/null +++ b/pnpm/.changeset/clean-ci-workspace-state.md @@ -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. diff --git a/pnpm/src/cmd/clean.ts b/pnpm/src/cmd/clean.ts index b0e4361039..2ca355f41d 100644 --- a/pnpm/src/cmd/clean.ts +++ b/pnpm/src/cmd/clean.ts @@ -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 { let items: string[] diff --git a/pnpm/test/clean.ts b/pnpm/test/clean.ts index cc65d8eb89..572097b7d1 100644 --- a/pnpm/test/clean.ts +++ b/pnpm/test/clean.ts @@ -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)