New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

esc-exit

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esc-exit - npm Package Compare versions

Comparing version

to
0.2.0

'use strict';
var readline = require('readline');
var rl;
module.exports = function () {
// don't unref if it's already listened to
if (process.stdin.listeners('keypress').length === 0) {
process.stdin.unref();
}
var rl = readline.createInterface({
rl = readline.createInterface({
input: process.stdin,

@@ -15,5 +11,4 @@ output: process.stdout

process.stdin.on('keypress', function(s, key) {
if (key.name === 'escape') {
process.stdin.on('keypress', function(ch, key) {
if (key && key.name === 'escape') {
process.exit();

@@ -23,1 +18,5 @@ }

};
module.exports.done = function () {
rl.close();
};
{
"name": "esc-exit",
"version": "0.1.0",
"version": "0.2.0",
"description": "Exit the process when the `esc` key is pressed",

@@ -16,3 +16,3 @@ "license": "MIT",

"scripts": {
"test": "mocha"
"test": "mocha && node test-done.js"
},

@@ -19,0 +19,0 @@ "files": [

@@ -24,4 +24,17 @@ # esc-exit [![Build Status](https://travis-ci.org/sindresorhus/esc-exit.svg?branch=master)](https://travis-ci.org/sindresorhus/esc-exit)

## API
Using this prevents the process from exiting normally.
There are multiple ways you can handle this:
- Call `escExit.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 `procces.stdin` afterwards. It will let the process exit normally.
- Call `process.exit()` to exit the process directly.
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)