Skip to content

Commit 5bc2b3c

Browse files
committed
Make file optional, read from stdin if not present
1 parent c1d5844 commit 5bc2b3c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

bin/md2gslides.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,13 @@ var parser = new ArgumentParser({
3939
});
4040

4141
parser.addArgument('file', {
42-
help: 'Path to markdown file to convert',
43-
required: false,
42+
help: 'Path to markdown file to convert, If omitted, reads from stdin',
43+
nargs: '?'
4444
});
4545
parser.addArgument(['-u', '--user'], {
4646
help: 'Email address of user',
4747
required: false,
48+
dest: 'user',
4849
defaultValue: 'default',
4950
});
5051
parser.addArgument(['-a', '--append'], {
@@ -164,12 +165,15 @@ function loadCss(theme) {
164165
}
165166

166167
function generateSlides(slideGenerator) {
167-
const file = args.file == 'STDIN' ? 0 : path.resolve(args.file);
168-
if (file != 0) {
168+
let source;
169+
if (args.file) {
170+
source = path.resolve(args.file);
169171
// Set working directory relative to markdown file
170-
process.chdir(path.dirname(file));
172+
process.chdir(path.dirname(source));
173+
} else {
174+
source = 0;
171175
}
172-
const input = fs.readFileSync(file, { encoding: 'UTF-8' });
176+
const input = fs.readFileSync(source, { encoding: 'UTF-8' });
173177
const css = loadCss(args.style);
174178

175179
return slideGenerator.generateFromMarkdown(input, {

0 commit comments

Comments
 (0)