Skip to content

Commit

Permalink
Merge pull request snyk#253 from snyk/feat/climessage-rename
Browse files Browse the repository at this point in the history
feat: Rename cliMessage to userMessage for consistency
  • Loading branch information
lili2311 committed Oct 24, 2018
2 parents be98a50 + d04d675 commit c98b8b3
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/cli/commands/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ function monitor() {
return res.data;
}

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

return chalk.bold.white('\nMonitoring ' + res.path + '...\n\n') +
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ function test() {
// HACK as there can be different errors, and we pass only the
// first one
error.code = (vulnerableResults[0] || errorResults[0]).code;
error.cliMessage = (vulnerableResults[0] || errorResults[0]).cliMessage;
error.userMessage = (vulnerableResults[0] || errorResults[0]).userMessage;
throw error;
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ module.exports.message = function (error) {
// try to lookup the error string based either on the error code OR
// the actual error.message (which can be "Unauthorized" for instance),
// otherwise send the error message back
message = error.cliMessage ||
message = error.userMessage ||
codes[error.code || error.message] ||
errors[error.code || error.message];
if (message) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function monitor(root, meta, info) {
} else {
var e = new Error('unexpected error: ' + body.message);
e.code = res.statusCode;
e.cliMessage = body && body.cliMessage;
e.userMessage = body && body.userMessage;
reject(e);
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/lib/snyk-test/npm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ function queryForVulns(data, modules, hasDevDependencies, root, options) {
body.error :
res.statusCode);

err.cliMessage = body && body.cliMessage;
err.userMessage = body && body.userMessage;
// this is the case where a local module has been tested, but
// doesn't have any production deps, but we've noted that they
// have dep deps, so we'll error with a more useful message
Expand Down
2 changes: 1 addition & 1 deletion src/lib/snyk-test/run-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function runTest(packageManager, root, options) {
body.error :
res.statusCode);

err.cliMessage = body && body.cliMessage;
err.userMessage = body && body.userMessage;
// this is the case where a local module has been tested, but
// doesn't have any production deps, but we've noted that they
// have dep deps, so we'll error with a more useful message
Expand Down
8 changes: 4 additions & 4 deletions test/acceptance/cli.acceptance.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,23 @@ test('test cli with multiple params: good and bad', function (t) {
});
});

test('cliMessage correctly bubbles with npm', function (t) {
test('userMessage correctly bubbles with npm', function (t) {
chdirWorkspaces();
return cli.test('npm-package', {org: 'missing-org'})
.then(function () {
t.fail('expect to error');
}).catch(function (error) {
t.equal(error.cliMessage, 'cli error message', 'got correct error message');
t.equal(error.userMessage, 'cli error message', 'got correct error message');
});
});

test('cliMessage correctly bubbles with everything other than npm', function (t) {
test('userMessage correctly bubbles with everything other than npm', function (t) {
chdirWorkspaces();
return cli.test('ruby-app', { org: 'missing-org' })
.then(function () {
t.fail('expect to error');
}).catch(function (error) {
t.equal(error.cliMessage, 'cli error message', 'got correct error message');
t.equal(error.userMessage, 'cli error message', 'got correct error message');
});
});

Expand Down
2 changes: 1 addition & 1 deletion test/acceptance/fake-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ module.exports = function (root, apikey) {
res.status(404);
res.send({
code: 404,
cliMessage: 'cli error message',
userMessage: 'cli error message',
});
return next();
}
Expand Down

0 comments on commit c98b8b3

Please sign in to comment.