Initial project import

This commit is contained in:
drjones
2026-06-13 17:36:44 -07:00
commit ad2a18cc8d
18471 changed files with 4497570 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
import { fromSharedEvent } from '../observables.js';
/**
* Kills processes and aborts further command spawning on output stream error (namely, SIGPIPE).
*/
export class OutputErrorHandler {
outputStream;
abortController;
constructor({ abortController, outputStream, }) {
this.abortController = abortController;
this.outputStream = outputStream;
}
handle(commands) {
const subscription = fromSharedEvent(this.outputStream, 'error').subscribe(() => {
commands.forEach((command) => command.kill());
// Avoid further commands from spawning, e.g. if `RestartProcess` is used.
this.abortController.abort();
});
return {
commands,
onFinish: () => subscription.unsubscribe(),
};
}
}