From f96891afeb8e4fadb6240ae3fce27fdf672cbf1f Mon Sep 17 00:00:00 2001 From: Thomas Jensen Date: Wed, 2 Sep 2020 10:55:31 +0200 Subject: [PATCH] Fix EPIPE error on destroyed stdout (CLI) Piping the output to a consumer that ends before reading all output (e.g. `head`) will result in an EPIPE error. --- cli.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cli.js b/cli.js index 7d44fbf..c7762e7 100755 --- a/cli.js +++ b/cli.js @@ -37,3 +37,7 @@ process.stdin .pipe(ndj.parse()) .pipe(csv(args)) .pipe(process.stdout) + .on('error', err => { + if (err.code === 'EPIPE') return + throw err + })