事件:'SIGINT'


【Event: 'SIGINT'

每当 input 流收到通常称为 SIGINTCtrl+C 输入时,就会触发 'SIGINT' 事件。如果在 input 流收到 SIGINT 时没有注册 'SIGINT' 事件监听器,将会触发 'pause' 事件。

调用监听器函数时不传入任何参数。

【The listener function is invoked without passing any arguments.】

rl.on('SIGINT', () => {
  rl.question('Are you sure you want to exit? ', (answer) => {
    if (answer.match(/^y(es)?$/i)) rl.pause();
  });
});