-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
40 lines (33 loc) · 1.03 KB
/
index.ts
File metadata and controls
40 lines (33 loc) · 1.03 KB
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
import dotenv from "dotenv"
import fs from "fs"
import * as _ from "lodash"
import logger from "loglevel-colored-level-prefix"
import path from "path"
import request from "request-promise-native"
import util from "util"
import HugoArticle from "./src/hugoArticle"
import WordpressArticle from "./src/wordpressArticle"
import program from "commander"
dotenv.config()
declare var log: any
const globalAny: any = global
globalAny.log = logger()
program
.option("-d, --debug", "debug mode")
.command("convert <article>", "convert article from hugo, and add it as draft to wordpress")
.option("-l, --live", "Actually push to wordpress")
.action((cmd, options) => {
if (program.debug) {
log.setLevel("debug")
log.debug("Turning on debug mode.")
}
try {
const hugoArticle = new HugoArticle({ filename: cmd })
hugoArticle.load()
const wordpressArticle = new WordpressArticle({ hugoArticle, ...options })
wordpressArticle.push()
} catch (err) {
log.error(err)
}
})
.parse(process.argv)