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'); });