fix: properly check modules purge confirmation answer (#8655)

This commit is contained in:
Jordan
2024-10-17 11:11:32 +11:00
committed by GitHub
parent 744711c8b3
commit f9a095c7c6
2 changed files with 8 additions and 2 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/get-context": patch
"pnpm": patch
---
Don't purge `node_modules`, when typing "n" in the prompt that asks whether to remove `node_modules` before installation [#8655](https://github.com/pnpm/pnpm/pull/8655).

View File

@@ -346,7 +346,7 @@ async function purgeModulesDirsOfImporters (
importers: ImporterToPurge[]
): Promise<void> {
if (opts.confirmModulesPurge ?? true) {
const confirmed = await enquirer.prompt({
const confirmed = await enquirer.prompt<{ question: boolean }>({
type: 'confirm',
name: 'question',
message: importers.length === 1
@@ -354,7 +354,7 @@ async function purgeModulesDirsOfImporters (
: 'The modules directories will be removed and reinstalled from scratch. Proceed?',
initial: true,
})
if (!confirmed) {
if (!confirmed.question) {
throw new PnpmError('ABORTED_REMOVE_MODULES_DIR', 'Aborted removal of modules directory')
}
}