Skip to content

Commit

Permalink
fix #1137 maybe ?
Browse files Browse the repository at this point in the history
  • Loading branch information
jshkurti committed Mar 30, 2015
1 parent 9ec2860 commit 9386fd6
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions lib/CliUx.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,26 @@ UX.miniDisplay = function(list) {

};

var safe_push = function() {
var argv = arguments;
var table = argv[0];

for (var i = 1; i < argv.length; ++i) {
var elem = argv[i];
if (elem[Object.keys(elem)[0]] === undefined
|| elem[Object.keys(elem)[0]] === null) {
elem[Object.keys(elem)[0]] = 'N/A';
}
else if (Array.isArray(elem[Object.keys(elem)[0]])) {
elem[Object.keys(elem)[0]].forEach(function(curr, j) {
if (curr === undefined || curr === null)
elem[Object.keys(elem)[0]][j] = 'N/A';
});
}
table.push(elem);
}
};

/**
* Description
* @method describeTable
Expand All @@ -57,19 +77,6 @@ UX.describeTable = function(process) {
throw new Error(pm2_env.created_at + ' is not a valid date: '+e.message, e.fileName, e.lineNumber);
}

var safe_push = function() {
var argv = arguments;
var table = argv[0];

for (var i = 1; i < argv.length; ++i) {
var elem = argv[i];
if (elem[Object.keys(elem)[0]] === undefined
|| elem[Object.keys(elem)[0]] === null)
elem[Object.keys(elem)[0]] = 'N/A';
table.push(elem);
}
};

console.log('Describing process with id %d - name %s', pm2_env.pm_id, pm2_env.name);
safe_push(table,
{ 'status' : colorStatus(pm2_env.status) },
Expand Down Expand Up @@ -125,7 +132,7 @@ UX.describeTable = function(process) {
var obj = {};
var value = pm2_env.axm_monitor[key].value || pm2_env.axm_monitor[key];
obj[key] = value;
table_probes.push(obj);
safe_push(table_probes, obj);
});

console.log(table_probes.toString());
Expand Down Expand Up @@ -172,7 +179,8 @@ UX.dispAsTable = function(list, interact_infos) {
l.monit.cpu + '%',
l.monit ? UX.bytesToSize(l.monit.memory, 3) : ''
];
module_table.push(obj);
safe_push(module_table, obj);
//module_table.push(obj);
}
else {
obj[key] = [
Expand All @@ -185,7 +193,8 @@ UX.dispAsTable = function(list, interact_infos) {
l.monit ? UX.bytesToSize(l.monit.memory, 3) : '',
l.pm2_env.watch ? chalk.green.bold('enabled') : chalk.grey('disabled')
];
app_table.push(obj);
safe_push(app_table, obj);
//app_table.push(obj);
}

});
Expand Down

0 comments on commit 9386fd6

Please sign in to comment.