Skip to content

Commit

Permalink
fix: better readability on monitor output
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton Drukh committed Sep 9, 2018
1 parent 1a30329 commit f455f65
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions cli/commands/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ var detect = require('../../lib/detect');
var plugins = require('../../lib/plugins');
var ModuleInfo = require('../../lib/module-info');

var SEPARATOR = '\n-------------------------------------------------------\n';

function monitor() {
var args = [].slice.call(arguments, 0);
var options = {};
Expand Down Expand Up @@ -150,11 +152,14 @@ function monitor() {
if (res.ok) {
return res.data;
}
if (res.data && res.data.cliMessage) {
return chalk.bold.red(res.data.cliMessage);
}
return '\nFor path `' + res.path + '`, ' + res.data.message;
}).join('\n');

var errorMessage = (res.data && res.data.cliMessage) ?
chalk.bold.red(res.data.cliMessage) :
(res.data ? res.data.message : 'Unknown error occurred.');

return chalk.bold.white('\nMonitoring ' + res.path + '...\n\n') +
errorMessage;
}).join('\n' + SEPARATOR);

if (results.every(function (res) {
return res.ok;
Expand All @@ -169,14 +174,13 @@ function monitor() {

function formatMonitorOutput(packageManager, res, manageUrl, isJson) {
var issues = res.licensesPolicy ? 'issues' : 'vulnerabilities';
var strOutput = (packageManager === 'yarn' ?
'A yarn.lock file was detected - continuing as a Yarn project.\n\n' : '') +
'\n\nProject path: ' + res.path +
'\nCaptured a snapshot of this project\'s dependencies.\n' +
'Explore this snapshot at ' + res.uri + '\n\n' +
var strOutput = chalk.bold.white('\nMonitoring ' + res.path + '...\n\n') +
(packageManager === 'yarn' ?
'A yarn.lock file was detected - continuing as a Yarn project.\n' : '') +
'Explore this snapshot at ' + res.uri + '\n\n' +
(res.isMonitored ?
'Notifications about newly disclosed ' + issues + ' related\n' +
'to these dependencies will be emailed to you.' :
'Notifications about newly disclosed ' + issues + ' related ' +
'to these dependencies will be emailed to you.\n' :
chalk.bold.red('Project is inactive, so notifications are turned ' +
'off.\nActivate this project here: ' + manageUrl + '\n\n')) +
(res.trialStarted ?
Expand Down

0 comments on commit f455f65

Please sign in to comment.