Publish curated ForgeFlow source from 2ed1787c0b52
ForgeFlow quality gate / quality (push) Successful in 4m12s
ForgeFlow quality gate / secret-scan (push) Successful in 7s

This commit is contained in:
NuklearRabbit committed 2026-09-29 22:50:57 +02:00
commit f60b269686
254 files changed
+46204

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
'use strict';
function isBrokenPipeError(error) {
return error?.code === 'EPIPE';
}
function installOutputPipeGuards({
stdout = process.stdout,
stderr = process.stderr,
onBrokenPipe = () => {}
} = {}) {
const guardedStreams = [stdout, stderr].filter(Boolean);
const handlers = guardedStreams.map((stream) => {
const handler = (error) => {
if (!isBrokenPipeError(error)) throw error;
onBrokenPipe(error);
};
stream.on('error', handler);
return { stream, handler };
});
return () => {
for (const { stream, handler } of handlers) stream.off('error', handler);
};
}
module.exports = { installOutputPipeGuards, isBrokenPipeError };