GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 9e2664...6ddc55 )
by Stefano
02:30
created

scripts/js/workspace.build.js   A

Complexity

Total Complexity 14
Complexity/F 3.5

Size

Lines of Code 78
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 10
dl 0
loc 78
rs 10
wmc 14
mnd 3
bc 11
fnc 4
bpm 2.75
cpm 3.5
noi 3

2 Functions

Rating   Name   Duplication   Size   Complexity  
A program.action 0 58 1
A workspace.build.js ➔ make_red 0 3 1
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 fs = require('fs');
7
8
program
9
  .usage('[options] <enviroment ...>')
10
  .arguments('<enviroment>')
11
  .action(function(enviroment) {
12
13
    shell.echo('Compile Workspace ('+enviroment+')');
14
15
    shell.cd('applications/workspace/');
16
17
    fs.readFile('config.php.dist', 'utf8', function (err,data) {
18
19
      if (err) {
20
        process.stderr.write(chalk.red("Errore in lettura: "+err));
21
        process.exit(1);
0 ignored issues
show
Compatibility Debugging Code Best Practice introduced by
Use of process.exit() is discouraged as it will potentially stop the complete node.js application. Consider quitting gracefully instead by throwing an Error.
Loading history...
22
      }
23
24
      var result;
25
      if ( enviroment === 'dev' ){
26
        result = data.replace(/##TYPE##/g, 'sqlite');
27
        result = result.replace(/##HOST##/g, 'ROOT_PATH.\'/../database/workspace.sqlite\'');
28
        result = result.replace(/##DBNAME##/g, '');
29
        result = result.replace(/##PASSWORD##/g, '');
30
        result = result.replace(/##USERNAME##/g, '');
31
        result = result.replace(/##LOGLEVEL##/g, 'Monolog\Logger::DEBUG');
32
      } else if ( enviroment === 'vagrant' ){
33
        result = data.replace(/##TYPE##/g, 'mysql');
34
        result = result.replace(/##HOST##/g, '\'localhost\'');
35
        result = result.replace(/##DBNAME##/g, 'workspace');
36
        result = result.replace(/##PASSWORD##/g, 'workspace');
37
        result = result.replace(/##USERNAME##/g, 'workspace');
38
        result = result.replace(/##LOGLEVEL##/g, 'Monolog\Logger::DEBUG');
39
      } else {
40
        // STAGING / PROD
41
        result = data.replace(/##TYPE##/g, 'mysql');
42
        if (
43
          !process.env.npm_package_config_database_host ||
44
          !process.env.npm_package_config_database_host ||
45
          !process.env.npm_package_config_database_dbname ||
46
          !process.env.npm_package_config_database_password ||
47
          !process.env.npm_package_config_database_username
48
        ) {
49
          process.stderr.write(chalk.red("Errore manca la configurazione in .npmrc"));
50
          process.exit(1);
0 ignored issues
show
Compatibility Debugging Code Best Practice introduced by
Use of process.exit() is discouraged as it will potentially stop the complete node.js application. Consider quitting gracefully instead by throwing an Error.
Loading history...
51
        }
52
        result = result.replace(/##HOST##/g, '\''+process.env.npm_package_config_database_host+'\'');
53
        result = result.replace(/##DBNAME##/g, process.env.npm_package_config_database_dbname);
54
        result = result.replace(/##PASSWORD##/g, process.env.npm_package_config_database_password);
55
        result = result.replace(/##USERNAME##/g, process.env.npm_package_config_database_username);
56
        result = result.replace(/##LOGLEVEL##/g, 'Monolog\Logger::INFO');
57
      }
58
59
60
      fs.writeFile('config.php', result, 'utf8', function (err) {
61
         if (err) {
62
           process.stderr.write(chalk.red("Errore in scrittura: "+err));
63
           process.exit(1);
0 ignored issues
show
Compatibility Debugging Code Best Practice introduced by
Use of process.exit() is discouraged as it will potentially stop the complete node.js application. Consider quitting gracefully instead by throwing an Error.
Loading history...
64
         }
65
      });
66
    });
67
68
  })
69
  .parse(process.argv);
70
71
72
if (!process.argv.slice(2).length) {
73
  program.outputHelp(make_red);
74
}
75
76
function make_red(txt) {
77
  return chalk.red(txt);
78
}
79