From 20ba3c945a7c5129852c70fa5722287be433d35d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Sko=C5=99epa?= Date: Wed, 14 Mar 2018 18:15:38 +0100 Subject: [PATCH] Use signal-exit package to detect exit instead of process.on('exit') Fixes #21 --- lockfile.js | 3 ++- package.json | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lockfile.js b/lockfile.js index fd49717..b3cfd2e 100644 --- a/lockfile.js +++ b/lockfile.js @@ -30,7 +30,8 @@ function hasOwnProperty (obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop) } -process.on('exit', function () { +var onExit = require('signal-exit') +onExit(function () { debug('exit listener') // cleanup Object.keys(locks).forEach(exports.unlockSync) diff --git a/package.json b/package.json index 5e2f70c..4c58750 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,9 @@ "directories": { "test": "test" }, - "dependencies": {}, + "dependencies": { + "signal-exit": "^3.0.2" + }, "devDependencies": { "tap": "^7.1.2", "touch": "0"