-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.js
63 lines (56 loc) · 1.26 KB
/
index.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/**
* Module dependencies.
*/
var meow = require('meow');
/**
* Local libs
*/
var converter = require('./lib/converter.js');
var cli = meow(
`
Usage
$ medium2gatsby <src_file_or_folder>
Options
--output, -o Destination folder for output files. Defaults to './'.
--template, -t Template used to generate post files.
--drafts, -d set flag to export drafts along with other posts. Default, false.
--help, -h Shows usage instructions
Examples
$ medium2gatsby . -o posts -t template.js
$ medium2gatsby 2018-04-02_Introducing-the-react-testing-library----e3a274307e65.html -o output -t template.js
`,
{
flags: {
drafts: {
type: 'boolean',
alias: 'd',
default: false
},
output: {
type: 'string',
alias: 'o',
},
template: {
type: 'string',
alias: 't',
},
},
},
);
/*
{
input: ['unicorns'],
flags: {rainbow: true},
...
}
*/
// show help if no args passed
if (cli.input.length < 1) {
cli.showHelp();
}
var srcPath = cli.input[0];
var destPath = cli.flags.output;
var templatePath = cli.flags.template;
var export_drafts = cli.flags.drafts;
converter.convert(srcPath, destPath, templatePath, export_drafts);
// foo(cli.input[0], cli.flags);