-
Notifications
You must be signed in to change notification settings - Fork 8
/
mtoi.js
executable file
·32 lines (27 loc) · 898 Bytes
/
mtoi.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#! /usr/bin/env node
var mtoi = require('./index.js');
var program = require('commander');
var path = require('path');
var fs = require('fs');
var pkg = require('./package');
program.version(pkg.version)
.option('-i, --input <path>', 'Input markdown file path')
.option('-o, --output <path>', 'Impress htmll file output path')
.on('--help', function () {
console.log(' Examples:');
console.log('');
console.log(' $ mtoi -i file.md -o file.html');
console.log('');
})
.parse(process.argv);
if (!program.input || !program.output) {
console.log('');
console.log(' Must have input and output arg!');
program.help();
process.exit();
}
var basePath = process.cwd();
var input = path.resolve(basePath, program.input);
var output = path.resolve(basePath, program.output);
var html = mtoi(input);
fs.writeFileSync(output, html);