mirror of
https://github.com/markedjs/marked.git
synced 2026-11-30 16:48:05 +01:00
fix(cli): honor positional input file (#3922)
This commit is contained in:
+4
-4
@@ -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();
|
||||
|
||||
@@ -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`,
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
# file
|
||||
Reference in New Issue
Block a user