Skip to content

Commit

Permalink
Add hidden stdin option
Browse files Browse the repository at this point in the history
Workaround for #93: Allow to disable reading from stdin by `--no-stdin`.
  • Loading branch information
yhatt committed May 9, 2019
1 parent 3b0ab09 commit e2ccd85
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/marp-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ export default async function(argv: string[] = []): Promise<number> {
group: OptionGroup.Basic,
type: 'boolean',
},
stdin: {
default: true,
describe: 'Read Markdown from stdin',
hidden: true, // It is an escape-hatch for advanced user
group: OptionGroup.Basic,
type: 'boolean',
},
pdf: {
conflicts: ['image'],
describe: 'Convert slide deck into PDF',
Expand Down Expand Up @@ -197,11 +204,14 @@ export default async function(argv: string[] = []): Promise<number> {
return File.findDir(cvtOpts.inputDir)
}

// Read from stdio
// (May disable by --no-stdin option to avoid hung up while reading)
// @see https://github.com/marp-team/marp-cli/issues/93
const stdin = args.stdin ? await File.stdin() : undefined

// Regular file finding powered by globby
return <File[]>(
[await File.stdin(), ...(await File.find(...config.files))].filter(
f => f
)
[stdin, ...(await File.find(...config.files))].filter(f => f)
)
}

Expand Down

0 comments on commit e2ccd85

Please sign in to comment.