fix: allow pnpm run -r to work with empty pnpm-workspace.yaml (#10520)

close #10497
This commit is contained in:
Ryo Matsukawa
2026-02-07 01:13:15 +09:00
committed by Zoltan Kochan
parent 8887218d97
commit f1cb40c4e1
3 changed files with 22 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
"pnpm": patch
---
Fixed `pnpm run -r` failing with "No projects matched the filters" when an empty `pnpm-workspace.yaml` exists [#10497](https://github.com/pnpm/pnpm/issues/10497).

View File

@@ -213,7 +213,7 @@ export async function main (inputArgv: string[]): Promise<void> {
const relativeWSDirPath = () => path.relative(process.cwd(), wsDir) || '.'
if (config.workspaceRoot) {
filters.push({ filter: `{${relativeWSDirPath()}}`, followProdDepsOnly: Boolean(config.filterProd.length) })
} else if (filters.length === 0 && workspaceDir && !config.includeWorkspaceRoot && (cmd === 'run' || cmd === 'exec' || cmd === 'add' || cmd === 'test')) {
} else if (filters.length === 0 && workspaceDir && config.workspacePackagePatterns && !config.includeWorkspaceRoot && (cmd === 'run' || cmd === 'exec' || cmd === 'add' || cmd === 'test')) {
filters.push({ filter: `!{${relativeWSDirPath()}}`, followProdDepsOnly: Boolean(config.filterProd.length) })
}

View File

@@ -61,6 +61,22 @@ test('no projects found', async () => {
}
})
test('empty pnpm-workspace.yaml should not break pnpm run -r', async () => {
prepare({
name: 'project',
version: '1.0.0',
scripts: {
test: 'echo Passed',
},
})
fs.writeFileSync('pnpm-workspace.yaml', '')
const { stdout, status } = execPnpmSync(['run', '-r', 'test'])
expect(status).toBe(0)
expect(stdout.toString()).toContain('Passed')
})
const invalidWorkspaceManifests = [
'pnpm-workspaces.yaml',
'pnpm-workspaces.yml',