diff --git a/src/Command/FindBuildConfigurationFileCommand.php b/src/Command/FindBuildConfigurationFileCommand.php new file mode 100644 index 0000000..ab7e93f --- /dev/null +++ b/src/Command/FindBuildConfigurationFileCommand.php @@ -0,0 +1,43 @@ +filesystem->exists($configFile)) { + throw new \RuntimeException(sprintf('%s not found', $configFile)); + } + + return $next($configFile); + } + + // Search for a configuration file in the order of the filenames within + // the array and continue if one exists. + foreach (self::$configFiles as $i) { + if ($this->filesystem->exists($i)) { + return $next($i); + } + } + + throw new \RuntimeException("No configuration file found"); + } +} diff --git a/src/Console/Command/GenerateCommand.php b/src/Console/Command/GenerateCommand.php index 25482a3..5d4dc3f 100644 --- a/src/Console/Command/GenerateCommand.php +++ b/src/Console/Command/GenerateCommand.php @@ -6,6 +6,7 @@ namespace App\Console\Command; use App\Command\CreateFinalConfigurationDataCommand; use App\Command\CreateListOfFilesToGenerateCommand; +use App\Command\FindBuildConfigurationFileCommand; use App\Command\GenerateConfigurationFilesCommand; use App\Command\ValidateConfigurationDataCommand; use App\DataTransferObject\ConfigDto; @@ -67,6 +68,7 @@ class GenerateCommand extends Command $isDryRun = $input->getOption(name: 'dry-run'); $pipelines = [ + new FindBuildConfigurationFileCommand($this->filesystem), new CreateFinalConfigurationDataCommand(), new ValidateConfigurationDataCommand(), new CreateListOfFilesToGenerateCommand(),