-
Notifications
You must be signed in to change notification settings - Fork 5
/
bin.js
executable file
·51 lines (49 loc) · 1.39 KB
/
bin.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
#! /usr/bin/env node
const prompt = require('inquirer').createPromptModule()
const fs = require('fs')
const serve = require('./serve')
const log = require('./log')
const action = process.argv[2]
if (!action) {
fs.access(`${process.cwd()}/.boowatheme`, err => {
if (!err) {
let theme = fs.readFileSync(`${process.cwd()}/.boowatheme`, 'utf8').trim()
require(`./lib`)(theme, true)
} else {
log.info('Press ^C at any time to quit.')
prompt([{
type: 'list',
name: 'theme',
message: 'choose a blog theme',
choices: [
'classic',
'code',
'austere'
]
}]).then(async anwsers => {
require(`./lib`)(anwsers.theme)
})
}
})
} else if (action === 'build') {
let theme = fs.readFileSync(`${process.cwd()}/.boowatheme`, 'utf8').trim()
require(`./lib/build.js`)(theme)
} else if (action === 'create') {
let theme = fs.readFileSync(`${process.cwd()}/.boowatheme`, 'utf8').trim()
let mdName = process.argv[3]
if (mdName) {
require(`./lib/create.js`)(mdName, theme)
} else {
prompt([{
type: 'input',
name: 'mdName',
message: 'markdown file name'
}]).then(async anwsers => {
log.info('Press ^C at any time to quit.')
require(`./lib/create.js`)(anwsers.mdName, theme)
})
}
} else if (action === 'serve') {
let port = process.argv[3]
serve(port)
}