From daa98967630aadf48cbe9a7c4d279a5c366aeedc Mon Sep 17 00:00:00 2001 From: Mathias Wulff Date: Wed, 14 Oct 2026 11:43:17 +1100 Subject: [PATCH] No warning when only a Windows line break is piped in The warning for piped data that is not used (#719) was skipped for empty data and for a single `\n`, but not for a single `\r\n`. This is the last part of #727 that was not already in main. Co-Authored-By: Claude Opus 5.5 --- src/engine.ts | 3 ++- test/cli/run.sh | 3 +++ test/js/fix/719.test.js | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/engine.ts b/src/engine.ts index 7726d03f..6cb51667 100644 --- a/src/engine.ts +++ b/src/engine.ts @@ -161,7 +161,8 @@ function handlePipedData(config) { !config.replacementJs && !config.pipedDataUsed && config.pipedData && - '\n' !== config.pipedData + '\n' !== config.pipedData && + '\r\n' !== config.pipedData ) { warn('Data is piped in, but no flag tells what to do with it. It is not used.'); } diff --git a/test/cli/run.sh b/test/cli/run.sh index 6abf25af..3454688c 100644 --- a/test/cli/run.sh +++ b/test/cli/run.sh @@ -302,6 +302,9 @@ assert_failure "printf x | rexreplace 'o' 'x' my.file -q 2>&1 | grep 'Data is p assert_failure "printf x | rexreplace 'o' 'x' my.file -P 2>&1 | grep 'Data is piped in'" assert_failure "printf x | rexreplace 'b' _ my.file -R 2>&1 | grep 'Data is piped in'" assert_failure "printf x | rexreplace 'b' 'pipe' my.file -j 2>&1 | grep 'Data is piped in'" +assert_failure "printf '' | rexreplace 'o' 'x' my.file 2>&1 | grep 'Data is piped in'" +assert_failure "printf '\n' | rexreplace 'o' 'x' my.file 2>&1 | grep 'Data is piped in'" +assert_failure "printf '\r\n' | rexreplace 'o' 'x' my.file 2>&1 | grep 'Data is piped in'" # RR_VOID_PIPE diff --git a/test/js/fix/719.test.js b/test/js/fix/719.test.js index ea46053c..e1cbadd2 100644 --- a/test/js/fix/719.test.js +++ b/test/js/fix/719.test.js @@ -36,7 +36,7 @@ describe('#719 a warning when piped data is not used', () => { expect(await Bun.file('my.file').text()).toBe('fooxar'); }); - test.each([null, '', '\n'])('is not given when %j is piped in', async (pipedData) => { + test.each([null, '', '\n', '\r\n'])('is not given when %j is piped in', async (pipedData) => { expect((await piped({pipedData})).err).toBe('my.file \n'); });