Skip to content

Commit 0f55a94

Browse files
Itai GendlerItai Gendler
authored andcommitted
Fix error messages in case of no auth contexts
1 parent 3c0f924 commit 0f55a94

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

lib/interface/cli/commands/auth/current-context.cmd.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,7 @@ const command = new Command({
2121
.example('codefresh auth current-context', 'Show active authentication context');
2222
},
2323
handler: async (argv) => {
24-
const currentContext = authManager.getCurrentContext();
25-
if (_.isUndefined(currentContext)) {
26-
throw new CFError('There are no contexts in cfconfig file');
27-
}
28-
if (currentContext) {
29-
await printTableForAuthContexts({ filter: 'current' });
30-
}
24+
await printTableForAuthContexts({ filter: 'current' });
3125
},
3226
});
3327

lib/interface/cli/helpers/auth.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ const debug = require('debug')('codefresh:cli:helpers:auth');
88
const colors = require('colors');
99

1010
const printTableForAuthContexts = ({ filter = 'all' }) => {
11+
const currentContext = authManager.getCurrentContext();
12+
if (!currentContext) {
13+
console.log('No authentication contexts. Please create an authentication context (see codefresh auth create-context --help)');
14+
return;
15+
}
16+
1117
let contexts;
1218
if (filter === 'all') {
1319
contexts = _.keys(authManager.getAllContexts());

lib/interface/cli/helpers/general.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const wrapHandler = (handler, requiresAuthentication) => {
2020
try {
2121
const authManager = require('../../../logic').auth.manager;
2222
if (requiresAuthentication && !authManager.getCurrentContext()) {
23-
printError('Authentication error: Please create an authentication context (see codefresh auth create-context --help)');
23+
printError(new CFError('Authentication error: Please create an authentication context (see codefresh auth create-context --help)'));
2424
process.exit(1);
2525
}
2626

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codefresh",
3-
"version": "0.8.31",
3+
"version": "0.8.32",
44
"description": "Codefresh command line utility",
55
"main": "index.js",
66
"preferGlobal": true,

0 commit comments

Comments
 (0)