Skip to content

Commit ec3a4e5

Browse files
xu91102Your Name
andauthored
fix(cli): honor an explicitly empty string input (#4113)
Co-authored-by: Your Name <[email protected]>
1 parent 6bbac0c commit ec3a4e5

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

‎bin/main.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export async function main(nodeProcess) {
153153
}
154154

155155
async function getData() {
156-
if (string) {
156+
if (string !== undefined) {
157157
return string;
158158
}
159159
if (input) {

‎test/unit/bin.test.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ describe('bin/marked', () => {
9898
args: ['--string', '# test'],
9999
stdout: '<h1>test</h1>',
100100
}));
101+
102+
it('--string accepts empty input instead of reading stdin', testInput({
103+
args: ['--string', ''],
104+
stdin: '# ignored',
105+
stdout: '\n',
106+
}));
101107
});
102108

103109
describe('config', () => {

0 commit comments

Comments
 (0)