-
Notifications
You must be signed in to change notification settings - Fork 17
/
md-notes.js
44 lines (40 loc) · 1.12 KB
/
md-notes.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
#!/usr/bin/env node
var inquirer = require('inquirer')
var fs = require('fs')
var path = require('path')
var questions = require('./questions').questions
inquirer
.prompt(questions)
.then((answers) => {
fs.copyFile(
path.join(__dirname, 'templates', answers.type + '.md'),
answers.type + '.md',
(err) => {
if (err) throw err
console.log(`Created ${answers.type}.md`)
}
)
fs.copyFile(
path.join(__dirname, 'themes', answers.theme, answers.type + '-style.less'),
answers.type + '-style.less',
(err) => {
if (err) throw err
console.log(`Created ${answers.type}-style.less`)
}
)
if (answers.directory) {
fs.mkdir('images', (err) => {
if (err != null && err.code !== 'EEXIST') throw err
console.log('Created images directory')
})
}
})
.catch((error) => {
if (error.isTtyError) {
// Prompt couldn't be rendered in the current environment
console.log('The environment could not be rendered')
} else {
// Something else when wrong
console.log('Unknown error occurred')
}
})