-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrexar.js
More file actions
executable file
·42 lines (35 loc) · 967 Bytes
/
rexar.js
File metadata and controls
executable file
·42 lines (35 loc) · 967 Bytes
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
let fs = require('fs');
let arg = process.argv[2];
let name = process.argv[3];
let commands = [];
commands['dist'] = [
'route',
'controller',
'model'
]
commands['public/js'] = [
'action',
'component',
'container',
'reducer'
]
if(arg.includes('make:')) {
let item = arg.split('make:')[1].trim();
for (var dir in commands) {
if(commands[dir].includes(item)) {
var filedir = `./${dir}/${item}s`;
var filename = `${filedir}/${name}.js`;
var template = `./vendor/templates/${item}/${item}.txt`;
// create new file
let content = fs.readFileSync(template, 'utf8');
fs.appendFile(filename, content, function (err) {
if (err) throw err;
console.log(item + ' created successfully');
});
return true;
}
}
} else {
console.log('incorrect syntax');
return false;
}