Skip to content
Myr

abort.js

This file

Path

lib/pipe/abort.js

21 lines · 818 bytes · JavaScript

Last changed by

Fix `.pipe()` and stream conversion edge casesSindre Sorhusbefore adoptiond3ec10d

History of this file

Take it

The walk stopped after 200 commits: lines older than 9f65b86 point at it.

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 1–2why, one step back
1import {aborted} from 'node:util';
2import {createNonCommandError} from './throw.js';

Fix `.pipe()` and stream conversion edge casesSindre Sorhusbefore adoptiond3ec10d

line 3why, one step back
3import {unpipeSubprocessStream} from './streaming.js';

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 4–12why, one step back
4
5// When passing an `unpipeSignal` option, abort piping when the signal is aborted.6// However, do not terminate the subprocesses.7export const unpipeOnAbort = (unpipeSignal, unpipeContext) => unpipeSignal === undefined8 ? []9 : [unpipeOnSignalAbort(unpipeSignal, unpipeContext)];1011const unpipeOnSignalAbort = async (unpipeSignal, {sourceStream, mergedStream, fileDescriptors, sourceOptions, startTime}) => {12 await aborted(unpipeSignal, sourceStream);

Fix `.pipe()` and stream conversion edge casesSindre Sorhusbefore adoptiond3ec10d

line 13why, one step back
13 await unpipeSubprocessStream(mergedStream, sourceStream);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 14–21why, one step back
14 const error = new Error('Pipe canceled by `unpipeSignal` option.');
15 throw createNonCommandError({16 error,17 fileDescriptors,18 sourceOptions,19 startTime,20 });21};