fix: throw error if no TTY instead of terminating with 0 exit code (#9960)

close #9744
This commit is contained in:
Tom Jenkinson
2025-09-12 11:07:01 +01:00
committed by GitHub
parent e792927841
commit 2ebd45a7f2
2 changed files with 10 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/core": patch
---
Throw a `ABORTED_REMOVE_MODULES_DIR_NO_TTY` error if there's no TTY instead of showing the prompt to ask for confirmation to remove the modules directory and immediately exiting with code 0.

View File

@@ -149,6 +149,11 @@ async function purgeModulesDirsOfImporters (
importers: ImporterToPurge[]
): Promise<void> {
if (opts.confirmModulesPurge ?? true) {
if (!process.stdin.isTTY) {
throw new PnpmError('ABORTED_REMOVE_MODULES_DIR_NO_TTY', 'Aborted removal of modules directory due to no TTY', {
hint: 'If you are running pnpm in CI, set the CI environment variable to "true".',
})
}
const confirmed = await enquirer.prompt<{ question: boolean }>({
type: 'confirm',
name: 'question',