fix: don't exclude workspace root from recursive

It's a fix because it fixes a regression introduced by 2e55dcf130,
and it's a patch-level change since it's a bug
  fix.
This commit is contained in:
Zoltan Kochan
2026-03-19 01:44:13 +01:00
parent 2e55dcf130
commit 4d2afef9be

View File

@@ -35,6 +35,10 @@ export const REPORTER_INITIALIZED = Symbol('reporterInitialized')
loudRejection()
function isRootOnlyPatterns (patterns: string[]): boolean {
return patterns.length === 1 && patterns[0] === '.'
}
// This prevents the program from crashing when the pipe's read side closes early
// (e.g., when running `pnpm config list | head`)
process.stdout.on('error', (err: NodeJS.ErrnoException) => {
@@ -210,7 +214,14 @@ 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.workspacePackagePatterns && !config.includeWorkspaceRoot && (cmd === 'run' || cmd === 'exec' || cmd === 'add' || cmd === 'test')) {
} else if (
filters.length === 0 &&
workspaceDir &&
config.workspacePackagePatterns &&
!isRootOnlyPatterns(config.workspacePackagePatterns) &&
!config.includeWorkspaceRoot &&
(cmd === 'run' || cmd === 'exec' || cmd === 'add' || cmd === 'test')
) {
filters.push({ filter: `!{${relativeWSDirPath()}}`, followProdDepsOnly: Boolean(config.filterProd.length) })
}