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',