@@ -7,15 +7,15 @@ import type { IIniObject, IIniObjectSection } from "js-ini";
77
88import { UserConfigurationError } from "../../../utils/errors.ts" ;
99
10- const AWS_CONFIG_FILE = path . join ( os . homedir ( ) , ".aws" , "config" ) ;
10+ const DEFAULT_AWS_CONFIG_FILE = path . join ( os . homedir ( ) , ".aws" , "config" ) ;
1111
1212/** Last-resort region when neither the call nor the profile supplies one. */
1313const DEFAULT_REGION = "us-east-1" ;
1414
1515/** Read and parse the AWS config file */
1616function readAWSConfigFile ( ) : IIniObject {
1717 try {
18- const configContent = fs . readFileSync ( AWS_CONFIG_FILE , "utf-8" ) ;
18+ const configContent = fs . readFileSync ( AWSConfig . AWS_CONFIG_FILE , "utf-8" ) ;
1919 return parse ( configContent , { comment : [ ";" , "#" ] } ) ;
2020 } catch ( error : unknown ) {
2121 if ( ( error as NodeJS . ErrnoException ) . code === "ENOENT" ) {
@@ -48,6 +48,12 @@ function getSectionForProfile(profile: string): IIniObjectSection | undefined {
4848 * profiles and regions.
4949 */
5050const AWSConfig = {
51+ /**
52+ * Path to the AWS config file. Exposed as a mutable property so tests can
53+ * repoint it at a fixture file instead of the developer's real config.
54+ */
55+ AWS_CONFIG_FILE : DEFAULT_AWS_CONFIG_FILE ,
56+
5157 /**
5258 * Return the names of profiles found in the AWS config file. This will include 'default'
5359 * as the name of the default profile.
0 commit comments