Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNeel Dani <neeldani@github.com>2022-08-02 18:57:02 +0300
committerGitHub <noreply@github.com>2022-08-02 18:57:02 +0300
commitd315ead7a7f6d531eb57cfa4350bb08949c60997 (patch)
tree5fcbf0617513e1685bc954889f5fa2d921f63a4e /lib
parent3c024ace60904c69e61da00e1fb56c0c1735804a (diff)
fix: gracefully exit login and publish commands on Ctrl+C (SIGINT) in the new webAuthn flow (#5243)
Diffstat (limited to 'lib')
-rw-r--r--lib/utils/open-url-prompt.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/utils/open-url-prompt.js b/lib/utils/open-url-prompt.js
index 3eb3ac288..290040e5d 100644
--- a/lib/utils/open-url-prompt.js
+++ b/lib/utils/open-url-prompt.js
@@ -34,6 +34,11 @@ const promptOpen = async (npm, url, title, prompt, emitter) => {
})
const tryOpen = await new Promise(resolve => {
+ rl.on('SIGINT', () => {
+ rl.close()
+ resolve('SIGINT')
+ })
+
rl.question(prompt, () => {
resolve(true)
})
@@ -50,6 +55,10 @@ const promptOpen = async (npm, url, title, prompt, emitter) => {
}
})
+ if (tryOpen === 'SIGINT') {
+ throw new Error('canceled')
+ }
+
if (!tryOpen) {
return
}