-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
48 lines (41 loc) · 1.35 KB
/
index.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
#!/usr/bin/env node
const copy = require('graceful-copy')
var inquirer = require('inquirer')
var path = require('path')
var program = require('commander')
program
.usage('[options] <file>')
.option('-b, --base', 'Base Template')
.option('-c, --crud', 'Crud Template')
.option('-d, --demo', 'Full Demo')
.option('-j, --json', 'Crud with json server Template')
.parse(process.argv)
var template = 'spa'
if (program.crud) template = 'spa-crud'
else if (program.json) template = 'spa-json'
else if (program.demo) template = 'spa-demo'
const folderName = program.args.shift() || '.'
const templatesPath = path.join(__dirname, 'templates', template)
const destinationPath = path.resolve(folderName)
inquirer.prompt([{
type: "confirm",
message: "Are you sure you want to create '" + folderName + "' from template '" + template + "'?",
name: "confirmed",
default: true
}])
.then((answers) => {
if (answers.confirmed) {
return finalize()
}
return false;
})
function finalize() {
copy(templatesPath, destinationPath, {clean: false})
.then(files => {
console.log('Files Coped to: ', destinationPath)
console.log(files)
}).catch(err => {
console.log(err.stack)
})
return true
}