-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
executable file
·43 lines (36 loc) · 1.13 KB
/
app.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
#!/usr/bin/env node
var app = {
chalk : require('chalk'),
clear : require('clear'),
figlet : require('figlet'),
program : require('commander'),
co : require('co'),
fileutils : require('./utils/file.utils')(),
prompt : require('co-prompt')
};
app.clear();
console.log(app.chalk.bold.yellow(app.figlet.textSync('SkyfallJS', { horizontalLayout: 'full' })));
var files = app.fileutils._getAllFilesFromFolder(__dirname + '/command/');
var memCommand = [];
for(var i=0; i < files.length; i++){
try {
var cmd = require(files[i])(app);
memCommand.push(cmd);
app.program.option(cmd.command+', '+cmd.flag,cmd.description);
} catch(e) {
console.log(app.chalk.red('Erro: ' + e));
}
}
app.program.parse(process.argv);
//bootstrap do comando.
for(var i=0; i < memCommand.length;i++){
var fu = eval('app.program.'+memCommand[i].flag.replace('--',''));
if(fu){
memCommand[i].bootstrap();
return;
}
}
//caso não digite nenhum opção eu mostro o helper
if(!app.program.args.length) {
app.program.help();
}