@@ -739,15 +739,15 @@ class FeatureToggles {
739739 ) ;
740740 }
741741
742- static _consolidatedConfigFilepaths ( configFilepath , configFilepaths ) {
742+ static async _consolidatedConfigFilepaths ( configFilepath , configFilepaths ) {
743743 const result = [ ] ;
744744 if ( configFilepath ) {
745745 result . push ( configFilepath ) ;
746746 }
747747 if ( configFilepaths ) {
748748 result . concat ( Object . values ( configFilepaths ) ) ;
749749 }
750- if ( result . length === 0 ) {
750+ if ( result . length === 0 && ( await tryPathReadable ( DEFAULT_CONFIG_FILEPATH ) ) ) {
751751 result . push ( DEFAULT_CONFIG_FILEPATH ) ;
752752 }
753753 return result ;
@@ -768,30 +768,32 @@ class FeatureToggles {
768768 return ;
769769 }
770770
771- const consolidatedConfigFilepaths = FeatureToggles . _consolidatedConfigFilepaths ( configFilepath , configFilepaths ) ;
772- const configFromFilesMap = { } ;
773- for ( const configFilepath of consolidatedConfigFilepaths ) {
774- try {
775- if ( await tryPathReadable ( configFilepath ) ) {
776- configFromFilesMap [ configFilepath ] = await FeatureToggles . readConfigFromFile ( configFilepath ) ;
777- }
778- } catch ( err ) {
779- throw new VError (
780- {
781- name : VERROR_CLUSTER_NAME ,
782- cause : err ,
783- info : {
784- configFilepath,
771+ const consolidatedConfigFilepaths = await FeatureToggles . _consolidatedConfigFilepaths (
772+ configFilepath ,
773+ configFilepaths
774+ ) ;
775+ const configFromFilesWithPath = await Promise . all (
776+ consolidatedConfigFilepaths . map ( async ( configFilepath ) => {
777+ try {
778+ return { configFilepath, configFromFile : await FeatureToggles . readConfigFromFile ( configFilepath ) } ;
779+ } catch ( err ) {
780+ throw new VError (
781+ {
782+ name : VERROR_CLUSTER_NAME ,
783+ cause : err ,
784+ info : {
785+ configFilepath,
786+ } ,
785787 } ,
786- } ,
787- "initialization aborted, could not read config file"
788- ) ;
789- }
790- }
788+ "initialization aborted, could not read config file"
789+ ) ;
790+ }
791+ } )
792+ ) ;
791793
792794 let toggleCounts ;
793795 try {
794- toggleCounts = this . _processConfig ( { configRuntime, configFromFilesMap , configAuto, configFilepath } ) ;
796+ toggleCounts = this . _processConfig ( { configRuntime, configFromFilesWithPath , configAuto, configFilepath } ) ;
795797 } catch ( err ) {
796798 throw new VError (
797799 {
0 commit comments