Require Node.js 10
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Sindre Sorhus · committed by Sindre Sorhus · parent df08cfb · Browse files · 4 files·+7 added−14 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+7 added−14 removed
- other:+7 added−14 removed
Provenance
- Commit
5a9c76f- Tree
a583bec- Author
Sindre Sorhus <sindresorhus@gmail.com>- Committer
Sindre Sorhus <sindresorhus@gmail.com>- Parent
df08cfb
4 files changed+7 added−14 removed
modified:lib/kill.js+5 added-5 removed
1234456770 unmodified lines7879808183828384858687888991909192939495969798100101991001011021031041054 unmodified lines'use strict';const os = require('os');const onExit = require('signal-exit');const pFinally = require('p-finally');
const DEFAULT_FORCE_KILL_TIMEOUT = 1000 * 5;
// Monkey-patches `childProcess.kill()` to add `forceKillAfterTimeout` behavior70 unmodified lines timeoutKill(spawned, killSignal, reject); }, timeout); });
const safeSpawnedPromise = pFinally(spawnedPromise, () => { const safeSpawnedPromise = spawnedPromise.finally(() => { clearTimeout(timeoutId); });
return Promise.race([timeoutPromise, safeSpawnedPromise]);};
// `cleanup` option handlingconst setExitHandler = (spawned, {cleanup, detached}, timedPromise) => {const setExitHandler = async (spawned, {cleanup, detached}, timedPromise) => { if (!cleanup || detached) { return timedPromise; }
const removeExitHandler = onExit(() => { spawned.kill(); });
// TODO: Use native "finally" syntax when targeting Node.js 10 return pFinally(timedPromise, removeExitHandler); return timedPromise.finally(() => { removeExitHandler(); });};
module.exports = { spawnedKill,4 unmodified linesmodified:lib/promise.js+1 added-6 removed
15 unmodified lines16171819202122232024252122232423 unmodified lines15 unmodified lines// The return value is a mixin of `childProcess` and `Promise`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;};
// Use promises instead of `child_process` events23 unmodified linesmodified:.travis.yml-1 removed
5 unmodified lines67891010115 unmodified linesnode_js: - '13' - '12' - '10' - '8'after_success: - './node_modules/.bin/nyc report --reporter=text-lcov | ./node_modules/.bin/coveralls'modified:package.json+1 added-2 removed
9 unmodified lines10 "email": "sindresorhus@gmail.com",11 "url": "sindresorhus.com"12 },13 "engines": {14- "node": "^8.12.0 || >=9.7.0"14+ "node": ">=10"15 },16 "scripts": {17 "test": "xo && nyc ava && tsd"18 },26 unmodified lines45 "is-stream": "^2.0.0",46 "merge-stream": "^2.0.0",47 "npm-run-path": "^4.0.0",48 "onetime": "^5.1.0",49- "p-finally": "^2.0.0",49 "signal-exit": "^3.0.2",50 "strip-final-newline": "^2.0.0"51 },52 "devDependencies": {19 unmodified lines