1.0.0 • Published 7 years ago

ctrlc-exit v1.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

ctrlc-exit Build Status

Exit the process when Ctrl+C is pressed

Useful for CLI tools when default behavior to exit is disabled (e.g. raw mode is enabled).

Install

$ npm install ctrlc-exit

Usage

const ctrlcExit = require('ctrlc-exit');

ctrlcExit();

API

Using this prevents the process from exiting normally.

There are multiple ways you can handle this:

  • Call ctrlcExit.done() when you're done listening. It will then let the process exit normally.
  • Use process.stdin.unref() if you don't intend to use process.stdin afterwards. It will let the process exit normally.
  • Call process.exit() to exit the process directly.

Related

License

MIT © Vadim Demedes

1.0.0

7 years ago