UNPKG

1.47 kBJavaScriptView Raw
1#!/usr/bin/env node
2const fs = require('fs')
3const grayson = require('./lib/grayson')
4const graysonPkg = require('./package.json')
5
6const defaults = require('./lib/_defaults.json')
7const argv = require('minimist')(process.argv.slice(2))
8const pkg = fs.existsSync(`${process.cwd()}/package.json`)
9 ? require(`${process.cwd()}/package.json`).grayson
10 ? require(`${process.cwd()}/package.json`).grayson
11 : {}
12 : {}
13
14const helpMessage = `
15USAGE:
16 $ grayson [options]
17
18OPTIONS:
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
26MODES:
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
32if (argv.version || argv.v) {
33 console.log(graysonPkg.version)
34}
35
36if (argv.help || argv.h) {
37 console.log(helpMessage)
38}
39
40if (!argv.output && argv.o) {
41 argv.output = argv.o
42}
43
44if (!argv.input && argv.i) {
45 argv.input = argv.i
46}
47
48if (!argv.mode && argv.m) {
49 argv.mode = argv.m
50}
51
52const metadata = Object.assign({}, defaults, pkg.metadata)
53const options = Object.assign({ input: process.cwd(), output: process.cwd() }, pkg, argv, { metadata })
54grayson(options)