@@ -112,7 +112,7 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {
112112 cfnStackPrefix : this . flags [ 'cfn-stack-prefix' ] ?? config . cfnStackPrefix ,
113113 ecrAccessRoleArn :
114114 this . flags [ 'ecr-access-role-arn' ] ?? config . ecrAccessRoleArn ,
115- profile : this . flags . profile ,
115+ profile : this . flags . profile ?? config . profile ,
116116 ssmRootPrefix : this . flags [ 'ssm-root-prefix' ] ?? config . ssmRootPrefix ,
117117 yes : this . flags . yes ,
118118 } ;
@@ -123,7 +123,7 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {
123123 * @author Benedikt Arnarsson
124124 * @param {string } msg error message to log before exiting.
125125 */
126- public exitWithError = ( msg ?: string ) => {
126+ public exitWithError = ( msg ?: string ) : never => {
127127 this . bye ( msg , 1 ) ;
128128 } ;
129129
@@ -132,7 +132,7 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {
132132 * @author Benedikt Arnarsson
133133 * @param {string } msg message to log before exiting.
134134 */
135- public exitWithSuccess = ( msg ?: string ) => {
135+ public exitWithSuccess = ( msg ?: string ) : never => {
136136 this . bye ( msg ) ;
137137 } ;
138138
@@ -217,9 +217,8 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {
217217 profile = 'default' ,
218218 keepSecretArns = false ,
219219 ) : Promise < DeployConfigData > {
220- const { app } = this . flags ;
221- const appPrefix = this . getAppPrefix ( ) ;
222220 try {
221+ const appPrefix = this . getAppPrefix ( ) ;
223222 const deployConfig = await DeployConfig . fromSsmParams (
224223 appPrefix ,
225224 keepSecretArns ,
@@ -228,12 +227,20 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {
228227
229228 return deployConfig ;
230229 } catch ( error ) {
230+ const { app } = this . flags ;
231231 if ( error instanceof AppNotFound ) {
232232 this . exitWithError ( `${ app } app configuration not found!` ) ;
233+ } else {
234+ // Usually, this will be a profile/credential related error
235+ this . exitWithError (
236+ `Unknown error when fetching configuration for ${ app } :\n\n${ error } ` ,
237+ ) ;
233238 }
234239 }
235240
236- return DeployConfig . generate ( this . context ) ;
241+ // Need this to satisfy TS
242+ // Should never be reached, due to the try-catch and this.exitWithError
243+ throw new Error ( 'This code is unreachable' ) ;
237244 }
238245
239246 /**
@@ -300,7 +307,7 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {
300307 * @param {string } [msg='bye!'] message to display before exiting.
301308 * @param {number } [exitCode=0] exit code.
302309 */
303- private bye ( msg = 'bye!' , exitCode = 0 ) {
310+ private bye ( msg = 'bye!' , exitCode = 0 ) : never {
304311 this . log ( msg ) ;
305312 this . exit ( exitCode ) ;
306313 }
0 commit comments