1 | #!/usr/bin/env node
|
2 | const fs = require('fs');
|
3 | const grayson = require('./lib/grayson');
|
4 | const graysonPkg = require('./package.json');
|
5 |
|
6 | const defaults = require('./lib/_defaults.json');
|
7 | const argv = require('minimist')(process.argv.slice(2));
|
8 | const pkg = fs.existsSync(`${process.cwd()}/package.json`)
|
9 | ? require(`${process.cwd()}/package.json`).grayson
|
10 | ? require(`${process.cwd()}/package.json`).grayson
|
11 | : {}
|
12 | : {};
|
13 |
|
14 | const helpMessage = `
|
15 | USAGE:
|
16 | $ grayson [options]
|
17 |
|
18 | OPTIONS:
|
19 |
|
20 | --help, -h Prints this message
|
21 | --version, -v Prints Grayson Version
|
22 | --input, -i Input: Specific MD file or directory of multiple MD files
|
23 | --output, -o Output: Target directory for generated HTML output
|
24 | --mode, -m Mode: "pages", "slides", "blog" -- defaults to "pages"
|
25 |
|
26 | MODES:
|
27 | Pages: Generate one HTML file per MD file input
|
28 | Slides: Outputs one HTML file with all MD content contained in ".slide" element
|
29 | Blog: Like pages, with the automatic generation of an "index.html" file if none given
|
30 | `;
|
31 |
|
32 | if(argv.version || argv.v){
|
33 | console.log(graysonPkg.version);
|
34 | }
|
35 |
|
36 | if(argv.help || argv.h){
|
37 | console.log(helpMessage);
|
38 | }
|
39 |
|
40 | if(!argv.output && argv.o){
|
41 | argv.output = argv.o;
|
42 | }
|
43 |
|
44 | if(!argv.input && argv.i){
|
45 | argv.input = argv.i;
|
46 | }
|
47 |
|
48 | if(!argv.mode && argv.m){
|
49 | argv.mode = argv.m;
|
50 | }
|
51 |
|
52 | const metadata = Object.assign({}, defaults, pkg.metadata);
|
53 | const options = Object.assign({ input: process.cwd(), output: process.cwd() }, pkg, argv, { metadata });
|
54 | grayson(options);
|