@@ -21,16 +21,6 @@ process.on('unhandledRejection', error => {
21
21
22
22
recursive ( path . resolve ( __dirname , 'commands' ) , ( err , files ) => {
23
23
const rootCommands = [ ] ;
24
-
25
- _ . forEach ( files , ( file ) => {
26
- if ( file . endsWith ( '.cmd.js' ) ) {
27
- const command = require ( file ) ;
28
- if ( command . isRoot ( ) ) {
29
- rootCommands . push ( command ) ;
30
- }
31
- }
32
- } ) ;
33
-
34
24
yargs
35
25
. env ( '' )
36
26
. options ( 'cfconfig' , {
@@ -40,15 +30,28 @@ recursive(path.resolve(__dirname, 'commands'), (err, files) => {
40
30
. config ( 'cfconfig' , 'Custom path for authentication contexts config file' , ( configFilePath ) => {
41
31
try {
42
32
authManager . loadContexts ( configFilePath , process . env . CF_API_KEY , process . env . CF_URL || DEFAULTS . URL ) ;
33
+ if ( _ . isEmpty ( authManager . getAllContexts ( ) ) ) {
34
+ printError ( 'Unauthorized error: Please create an authentication context (see codefresh auth create-context --help)' ) ;
35
+ process . exit ( 1 ) ;
36
+ }
37
+ _ . forEach ( files , ( file ) => {
38
+ if ( file . endsWith ( '.cmd.js' ) ) {
39
+ const command = require ( file ) ;
40
+ if ( command . isRoot ( ) && ( ! command . isBetaCommand ( ) || authManager . getCurrentContext ( ) . beta ) ) {
41
+ rootCommands . push ( command ) ;
42
+ }
43
+ }
44
+ } ) ;
45
+ _ . forEach ( rootCommands , ( command ) => {
46
+ yargs . command ( command . toCommand ( ) ) ;
47
+ } ) ;
43
48
} catch ( err ) {
44
49
printError ( err ) ;
45
50
process . exit ( 1 ) ;
46
51
}
47
52
} ) ;
48
53
49
- _ . forEach ( rootCommands , ( command ) => {
50
- yargs . command ( command . toCommand ( ) ) ;
51
- } ) ;
54
+
52
55
53
56
54
57
yargs // eslint-disable-line
0 commit comments