From 5a9c76fbcc88ccd29e63b76ba033553dbbe4ac2a Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Wed, 18 Dec 2019 20:24:43 +0100 Subject: [PATCH] Require Node.js 10 --- .travis.yml | 1 - lib/kill.js | 10 +++++----- lib/promise.js | 7 +------ package.json | 3 +-- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index 010a4b78c..f298d644b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,5 @@ node_js: - '13' - '12' - '10' - - '8' after_success: - './node_modules/.bin/nyc report --reporter=text-lcov | ./node_modules/.bin/coveralls' diff --git a/lib/kill.js b/lib/kill.js index 813cf2e08..03e462748 100644 --- a/lib/kill.js +++ b/lib/kill.js @@ -1,7 +1,6 @@ 'use strict'; const os = require('os'); const onExit = require('signal-exit'); -const pFinally = require('p-finally'); const DEFAULT_FORCE_KILL_TIMEOUT = 1000 * 5; @@ -80,7 +79,7 @@ const setupTimeout = (spawned, {timeout, killSignal = 'SIGTERM'}, spawnedPromise }, timeout); }); - const safeSpawnedPromise = pFinally(spawnedPromise, () => { + const safeSpawnedPromise = spawnedPromise.finally(() => { clearTimeout(timeoutId); }); @@ -88,7 +87,7 @@ const setupTimeout = (spawned, {timeout, killSignal = 'SIGTERM'}, spawnedPromise }; // `cleanup` option handling -const setExitHandler = (spawned, {cleanup, detached}, timedPromise) => { +const setExitHandler = async (spawned, {cleanup, detached}, timedPromise) => { if (!cleanup || detached) { return timedPromise; } @@ -97,8 +96,9 @@ const setExitHandler = (spawned, {cleanup, detached}, timedPromise) => { spawned.kill(); }); - // TODO: Use native "finally" syntax when targeting Node.js 10 - return pFinally(timedPromise, removeExitHandler); + return timedPromise.finally(() => { + removeExitHandler(); + }); }; module.exports = { diff --git a/lib/promise.js b/lib/promise.js index 34773d591..42ab0ddf4 100644 --- a/lib/promise.js +++ b/lib/promise.js @@ -17,12 +17,7 @@ const mergePromiseProperty = (spawned, promise, property) => { const mergePromise = (spawned, promise) => { mergePromiseProperty(spawned, promise, 'then'); mergePromiseProperty(spawned, promise, 'catch'); - - // TODO: Remove the `if`-guard when targeting Node.js 10 - if (Promise.prototype.finally) { - mergePromiseProperty(spawned, promise, 'finally'); - } - + mergePromiseProperty(spawned, promise, 'finally'); return spawned; }; diff --git a/package.json b/package.json index 55cf891a0..4d701668c 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "url": "sindresorhus.com" }, "engines": { - "node": "^8.12.0 || >=9.7.0" + "node": ">=10" }, "scripts": { "test": "xo && nyc ava && tsd" @@ -46,7 +46,6 @@ "merge-stream": "^2.0.0", "npm-run-path": "^4.0.0", "onetime": "^5.1.0", - "p-finally": "^2.0.0", "signal-exit": "^3.0.2", "strip-final-newline": "^2.0.0" },