cleanup.js
This file
Path
lib/terminate/cleanup.js
16 lines · 411 bytes · JavaScript
Last changed by
Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf
History of this fileTake it
The walk stopped after 200 commits: lines older than 9f65b86 point at it.
100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 1–4why, one step back1import {addAbortListener} from 'node:events';2import {onExit} from 'signal-exit';34// If the `cleanup` option is used, call `subprocess.kill()` when the parent process exitsAdd `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf
line 5why, one step back5export const cleanupOnExit = (kill, {cleanup, detached}, {signal}) => {100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 6–10why, one step back6 if (!cleanup || detached) {7 return;8 }910 const removeExitHandler = onExit(() => {Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf
line 11why, one step back11 kill();100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 12–16why, one step back12 });13 addAbortListener(signal, () => {14 removeExitHandler();15 });16};