-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsetupTemplates.js
35 lines (30 loc) · 1.07 KB
/
setupTemplates.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
const ora = require('ora'),
ncp = require('ncp'),
chalk = require('chalk'),
pathObj = require('path'),
types = {
h: 'handlebars',
handlebars: 'handlebars',
d: 'dot',
dot: 'dot'
};
module.exports = (type, mainTargetDir) => {
const spinner = ora({
text: `Setting up ${types[type]} templates...`,
spinner: 'star2',
color: 'yellow'
}),
templatePath = pathObj.join(__dirname, '/../templates/');
spinner.start();
switch (types[type]) {
case 'handlebars':
ncp(pathObj.join(templatePath, 'handlebars/templates'), pathObj.join(mainTargetDir, 'templates'));
ncp(pathObj.join(templatePath, 'handlebars/routes'), pathObj.join(mainTargetDir, 'routes'));
break;
default:
// do the dot templates here
ncp(pathObj.join(templatePath, 'dot/templates'), pathObj.join(mainTargetDir, 'templates'));
ncp(pathObj.join(templatePath, 'dot/routes'), pathObj.join(mainTargetDir, 'routes'));
}
spinner.stopAndPersist({ symbol: chalk.green('✔') });
};