mirror of
https://github.com/pnpm/pnpm.git
synced 2025-12-26 08:38:09 -05:00
fix(update): cancelling interactive update
This commit is contained in:
6
.changeset/polite-points-behave.md
Normal file
6
.changeset/polite-points-behave.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/plugin-commands-installation": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
Don't crash when `pnpm update --interactive` is cancelled with Ctrl+c.
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
import { CompletionFunc } from '@pnpm/command'
|
||||
import { FILTERING, OPTIONS, UNIVERSAL_OPTIONS } from '@pnpm/common-cli-options-help'
|
||||
import { types as allTypes } from '@pnpm/config'
|
||||
import { globalInfo } from '@pnpm/logger'
|
||||
import matcher from '@pnpm/matcher'
|
||||
import { outdatedDepsOfProjects } from '@pnpm/outdated'
|
||||
import { prompt } from 'enquirer'
|
||||
@@ -236,6 +237,13 @@ async function interactiveUpdate (
|
||||
k () {
|
||||
return this.up()
|
||||
},
|
||||
cancel () {
|
||||
// By default, canceling the prompt via Ctrl+c throws an empty string.
|
||||
// The custom cancel function prevents that behavior.
|
||||
// Otherwise, pnpm CLI would print an error and confuse users.
|
||||
// See related issue: https://github.com/enquirer/enquirer/issues/225
|
||||
globalInfo('Update canceled')
|
||||
},
|
||||
} as any) as any // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||
return update(updateDependencies, opts)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user