diff options
author | Neel Dani <neeldani@github.com> | 2022-08-02 18:57:02 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-02 18:57:02 +0300 |
commit | d315ead7a7f6d531eb57cfa4350bb08949c60997 (patch) | |
tree | 5fcbf0617513e1685bc954889f5fa2d921f63a4e /lib | |
parent | 3c024ace60904c69e61da00e1fb56c0c1735804a (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.js | 9 |
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 } |