@@ -138,6 +138,18 @@ export default class Maestro extends BaseProvider<MaestroOptions> {
138138 } ) ,
139139 ] ;
140140
141+ if ( this . options . configFile ) {
142+ fileChecks . push (
143+ fs . promises
144+ . access ( this . options . configFile , fs . constants . R_OK )
145+ . catch ( ( ) => {
146+ throw new TestingBotError (
147+ `Specified config file does not exist: ${ this . options . configFile } ` ,
148+ ) ;
149+ } ) ,
150+ ) ;
151+ }
152+
141153 // Check if all flows paths exist (can be files, directories or glob patterns)
142154 for ( const flowsPath of this . options . flows ) {
143155 const isGlobPattern =
@@ -669,9 +681,15 @@ export default class Maestro extends BaseProvider<MaestroOptions> {
669681 let configPath : string | null = null ;
670682 let config : MaestroConfig | null = null ;
671683
672- // Check for config.yaml or config.yml
673- for ( const configName of [ 'config.yaml' , 'config.yml' ] ) {
674- const candidatePath = path . join ( directory , configName ) ;
684+ // If a custom config file is specified, use it; otherwise check for config.yaml or config.yml
685+ const configCandidates = this . options . configFile
686+ ? [ path . resolve ( this . options . configFile ) ]
687+ : [
688+ path . join ( directory , 'config.yaml' ) ,
689+ path . join ( directory , 'config.yml' ) ,
690+ ] ;
691+
692+ for ( const candidatePath of configCandidates ) {
675693 try {
676694 const configContent = await fs . promises . readFile (
677695 candidatePath ,
@@ -768,7 +786,13 @@ export default class Maestro extends BaseProvider<MaestroOptions> {
768786 */
769787 private isConfigFile ( filePath : string ) : boolean {
770788 const basename = path . basename ( filePath ) ;
771- return basename === 'config.yaml' || basename === 'config.yml' ;
789+ if ( basename === 'config.yaml' || basename === 'config.yml' ) {
790+ return true ;
791+ }
792+ if ( this . options . configFile ) {
793+ return basename === path . basename ( this . options . configFile ) ;
794+ }
795+ return false ;
772796 }
773797
774798 private async readFlowTags ( flowFile : string ) : Promise < string [ ] > {
@@ -799,8 +823,14 @@ export default class Maestro extends BaseProvider<MaestroOptions> {
799823 private async loadConfigTags (
800824 baseDir : string ,
801825 ) : Promise < { includeTags ?: string [ ] ; excludeTags ?: string [ ] } > {
802- for ( const configName of [ 'config.yaml' , 'config.yml' ] ) {
803- const candidate = path . join ( baseDir , configName ) ;
826+ const candidates = this . options . configFile
827+ ? [ path . resolve ( this . options . configFile ) ]
828+ : [
829+ path . join ( baseDir , 'config.yaml' ) ,
830+ path . join ( baseDir , 'config.yml' ) ,
831+ ] ;
832+
833+ for ( const candidate of candidates ) {
804834 try {
805835 const content = await fs . promises . readFile ( candidate , 'utf-8' ) ;
806836 const parsed = yaml . load ( content ) as MaestroConfig | null ;
0 commit comments