Total Complexity | 5 |
Complexity/F | 2.5 |
Lines of Code | 59 |
Function Count | 2 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 1 | Features | 0 |
1 | var program = require('commander'); |
||
2 | var shell = require('shelljs'); |
||
3 | var chalk = require('chalk'); |
||
4 | var co = require('co'); |
||
5 | var prompt = require('co-prompt'); |
||
6 | var rimraf = require('rimraf'); |
||
7 | |||
8 | program |
||
9 | .usage('[options] <enviroment ...>') |
||
10 | .arguments('<enviroment>') |
||
11 | .action(function(enviroment) { |
||
12 | |||
13 | shell.mkdir('-p',['applications/assets/icons']); |
||
14 | |||
15 | shell.echo('Build Server Vagrant ('+enviroment+')'); |
||
16 | |||
17 | if ( enviroment === 'dev' ){ |
||
18 | |||
19 | // SSH |
||
20 | rimraf('server/plays/ssh/*.key'); |
||
21 | rimraf('server/plays/ssh/*.pub'); |
||
22 | |||
23 | // SSL |
||
24 | rimraf('server/plays/ssl/*.key'); |
||
25 | rimraf('server/plays/ssl/*.crt'); |
||
26 | rimraf('server/plays/ssl/*.pem'); |
||
27 | |||
28 | // ANSIBLE ROLE |
||
29 | rimraf('server/roles/external/*'); |
||
30 | |||
31 | shell.cd('server'); |
||
32 | |||
33 | destroyVagrantServer = shell.exec('vagrant destroy -f'); |
||
|
|||
34 | |||
35 | if ( destroyVagrantServer.code !== 0 ){ |
||
36 | //ERRORE |
||
37 | process.stderr.write(chalk.red("Errore: "+destroyVagrantServer.stderr+ " - "+destroyVagrantServer.output)); |
||
38 | process.exit(1); |
||
39 | } |
||
40 | |||
41 | shell.cd('..'); |
||
42 | |||
43 | } else { |
||
44 | |||
45 | //NOTHING ??? |
||
46 | |||
47 | } |
||
48 | |||
49 | }) |
||
50 | .parse(process.argv); |
||
51 | |||
52 | |||
53 | if (!process.argv.slice(2).length) { |
||
54 | program.outputHelp(make_red); |
||
55 | } |
||
56 | |||
57 | function make_red(txt) { |
||
58 | return chalk.red(txt); //display the help text in red on the console |
||
59 | } |
||
60 |