-
Notifications
You must be signed in to change notification settings - Fork 0
/
io.js
44 lines (41 loc) · 1.44 KB
/
io.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
const PATH = require('./node/path.js');
const Creator = require('./node/creator.js');
const Watcher = require('./node/watcher.js');
var fs = require('fs');
var argv = {
flag: process.argv[2],
list: process.argv.slice(3)
}
if (process.argv.length > 1) {
switch (argv.flag){
case '-cb':
var fileBlocks = PATH.PUG + 'blocks.txt';
for (let item of argv.list) {
var name = item;
new Creator(name, PATH.BLOCKS, ['.sass', '.pug', '.js'], {true: `Блок ${name} успешно создан`, false: `Блок ${name} уже имеется`})
var blocks = fs.readFileSync(fileBlocks);
fs.writeFileSync(fileBlocks, blocks + `//- ${item} \n+style('${item}', 'blocks')\ninclude ../../blocks/${item}/${item}\n\n`);
}
break;
case '-cc':
for (let item of argv.list) {
var name = item.replace(/[\W\d]/g,'')
new Creator(name, PATH.COMPS, ['.sass', '.pug', '.js'], {true: `Компонент ${name} успешно создан`, false: `Компонент ${name} уже имеется`})
}
break;
case '-cp':
for (let item of argv.list) {
var name = item;
new Creator(name, PATH.PAGES, ['.pug'], {true: `Страница ${name} успешно создан`, false: `Страница ${name} уже имеется`})
var opn = require('opn');
opn('localhost:3000/' + name + '.html');
}
break;
case '-w':
new Watcher();
break;
case '-ww':
Watcher.compilePages();
break;
}
}