fix(cli): honor positional input file (#3922)

This commit is contained in:
Nandan
2026-04-05 00:00:28 -06:00
committed by GitHub
parent 3b59e81a1b
commit a1c2617a37
3 changed files with 10 additions and 4 deletions
+4 -4
View File
@@ -152,11 +152,11 @@ export async function main(nodeProcess) {
}
async function getData() {
if (string) {
return string;
}
if (!input) {
if (files.length <= 2) {
if (string) {
return string;
}
if (files.length === 0) {
return await getStdin();
}
input = files.pop();
+5
View File
@@ -99,6 +99,11 @@ describe('bin/marked', () => {
});
describe('input', () => {
it('input file positional', testInput({
args: [fixturePath('bin-input.md')],
stdout: '<h1>file</h1>',
}));
it('input file not found', testInput({
args: [fixturePath('does-not-exist.md')],
stderr: `marked: ${fixturePath('does-not-exist.md')}: No such file or directory`,
+1
View File
@@ -0,0 +1 @@
# file