-
Notifications
You must be signed in to change notification settings - Fork 11
/
fliplet-create-theme.js
48 lines (39 loc) · 1.01 KB
/
fliplet-create-theme.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
const path = require('path');
const replace = require('replace');
const ncp = require('ncp').ncp;
ncp.limit = 16;
if (process.argv.length < 3) {
log('Theme name is required');
process.exit();
}
const widgetName = process.argv[2];
const packageName = widgetName.trim().replace(/ /g, '-').toLowerCase();
const folderPath = path.join(process.cwd(), packageName);
log('Creating new theme', widgetName, 'to', folderPath);
ncp(path.join(__dirname, 'theme-template'), folderPath, function(err) {
if (err) {
return console.error(err);
}
replace({
regex: '{{name}}',
replacement: widgetName,
paths: [folderPath],
recursive: true,
silent: true
});
replace({
regex: '{{package}}',
replacement: packageName,
paths: [folderPath],
recursive: true,
silent: true
});
log('Theme has been successfully created. To run it for development:');
log('');
log(' $ cd ' + packageName);
log(' $ fliplet run');
log('');
});
function log() {
console.log.apply(this, arguments);
}