enquirer: esc is fine, but after first prompt SIGINT will be ignore; onRawSIGINT keeps process running -> switch to inquirer
This commit is contained in:
parent
97ef14f514
commit
6aea18836d
3 changed files with 35 additions and 8 deletions
|
|
@ -1,10 +1,10 @@
|
|||
// https://github.com/enquirer/enquirer/issues/372
|
||||
import { prompt } from '../src/util.js';
|
||||
import { prompt, handleSIGINT } from '../src/util.js';
|
||||
|
||||
const handleSIGINT = () => process.on('SIGINT', () => { // e.g. when killed by Ctrl-C
|
||||
console.log('\nInterrupted by SIGINT. Exit!');
|
||||
process.exitCode = 130;
|
||||
});
|
||||
// const handleSIGINT = () => process.on('SIGINT', () => { // e.g. when killed by Ctrl-C
|
||||
// console.log('\nInterrupted by SIGINT. Exit!');
|
||||
// process.exitCode = 130;
|
||||
// });
|
||||
handleSIGINT();
|
||||
|
||||
function onRawSIGINT(fn) {
|
||||
|
|
@ -20,15 +20,16 @@ function onRawSIGINT(fn) {
|
|||
}
|
||||
});
|
||||
}
|
||||
onRawSIGINT(() => {
|
||||
console.log('raw'); process.exit(1);
|
||||
});
|
||||
// onRawSIGINT(() => {
|
||||
// console.log('raw'); process.exit(1);
|
||||
// });
|
||||
|
||||
console.log('hello');
|
||||
console.error('hello error');
|
||||
try {
|
||||
let i = 'foo';
|
||||
i = await prompt(); // SIGINT no longer handled if this is executed
|
||||
i = await prompt(); // SIGINT no longer handled if this is executed
|
||||
// handleSIGINT();
|
||||
console.log('value:', i);
|
||||
setTimeout(() => console.log('timeout 3s'), 3000);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue