-
Notifications
You must be signed in to change notification settings - Fork 13
/
creator.js
33 lines (28 loc) · 917 Bytes
/
creator.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
'use strict'
const fs = require('fs-extra')
const path = require('path')
const init = (destination = '.', overwrite = false, {dryrun = false, verbose = false}) => {
const realTplPath = path.resolve(__dirname, 'template')
const realDestPath = path.resolve(destination)
if (verbose || dryrun) {
console.log('[V] Output dir:', destination)
console.log('[V] Overwrite:', overwrite)
console.log('[V] Template source path:', realTplPath)
console.log('[V] Template output destination', realDestPath)
}
if (dryrun) {
console.log(`ef.qt project has NOT been generated in \`${realDestPath}'. (--dryrun)`)
return
}
fs.ensureDir(realDestPath, (err) => {
if (err) throw err
fs.copy(realTplPath, realDestPath, {
overwrite: overwrite,
errorOnExist: true
}, (err) => {
if (err) throw err
console.log(`ef.qt project has been generated in \`${realDestPath}'`)
})
})
}
module.exports = init