From 2ebd45a7f265ea7745d6dc313d7f8a5cfa6525e3 Mon Sep 17 00:00:00 2001 From: Tom Jenkinson Date: Fri, 12 Sep 2025 11:07:01 +0100 Subject: [PATCH] fix: throw error if no TTY instead of terminating with 0 exit code (#9960) close #9744 --- .changeset/slimy-baths-tan.md | 5 +++++ pkg-manager/core/src/install/validateModules.ts | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 .changeset/slimy-baths-tan.md diff --git a/.changeset/slimy-baths-tan.md b/.changeset/slimy-baths-tan.md new file mode 100644 index 0000000000..7cca7ebfce --- /dev/null +++ b/.changeset/slimy-baths-tan.md @@ -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. diff --git a/pkg-manager/core/src/install/validateModules.ts b/pkg-manager/core/src/install/validateModules.ts index 6eb58069a1..2ac3052f9f 100644 --- a/pkg-manager/core/src/install/validateModules.ts +++ b/pkg-manager/core/src/install/validateModules.ts @@ -149,6 +149,11 @@ async function purgeModulesDirsOfImporters ( importers: ImporterToPurge[] ): Promise { 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',