From ec3a4e511aa0d60b3e9ab8aa0c769407cdaf08d9 Mon Sep 17 00:00:00 2001 From: hhang <17309584214@163.com> Date: Tue, 6 Oct 2026 22:56:05 +0800 Subject: [PATCH] fix(cli): honor an explicitly empty string input (#4113) Co-authored-by: Your Name --- bin/main.js | 2 +- test/unit/bin.test.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/main.js b/bin/main.js index 76fa6c07..643879aa 100644 --- a/bin/main.js +++ b/bin/main.js @@ -153,7 +153,7 @@ export async function main(nodeProcess) { } async function getData() { - if (string) { + if (string !== undefined) { return string; } if (input) { diff --git a/test/unit/bin.test.js b/test/unit/bin.test.js index e0b2bf71..943f0d6c 100644 --- a/test/unit/bin.test.js +++ b/test/unit/bin.test.js @@ -98,6 +98,12 @@ describe('bin/marked', () => { args: ['--string', '# test'], stdout: '

test

', })); + + it('--string accepts empty input instead of reading stdin', testInput({ + args: ['--string', ''], + stdin: '# ignored', + stdout: '\n', + })); }); describe('config', () => {