Skip to content

Commit

Permalink
Fix fatal error if config/env does not exists
Browse files Browse the repository at this point in the history
See #20
  • Loading branch information
gmazzap committed May 6, 2024
1 parent 888ffd7 commit e9588b6
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions src/Task/CopyDevPaths.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,7 @@ private function pathInfoForKey(string $key): array
case Config::DEV_PATHS_PHP_CONFIG_DIR_KEY:
$what = 'PHP config files';
$target = $this->directories->phpConfigDir();
if ($finder) {
$finder = $finder->ignoreDotFiles(true)->exclude('env');
$envs = Finder::create()
->in("{$source}/env")
->depth('== 0')
->ignoreUnreadableDirs()
->ignoreVCS(true)
->ignoreDotFiles(true);
$finder = $finder->append($envs);
}
$finder and $finder = $this->pathInfoForPhpConfigDir($finder, $source);
break;
case Config::DEV_PATHS_YAML_CONFIG_DIR_KEY:
$what = 'Yaml config files';
Expand All @@ -217,6 +208,28 @@ static function (SplFileInfo $info): bool {
return [$what, $source, $target, $finder];
}

/**
* @param Finder $finder
* @param string $source
* @return Finder
*/
private function pathInfoForPhpConfigDir(Finder $finder, string $source): Finder
{
$finder = $finder->ignoreDotFiles(true)->exclude('env');
if (!is_dir("{$source}/env")) {
return $finder;
}

$envs = Finder::create()
->in("{$source}/env")
->depth('== 0')
->ignoreUnreadableDirs()
->ignoreVCS(true)
->ignoreDotFiles(true);

return $finder->append($envs);
}

/**
* @param Io $io
* @return int
Expand Down

0 comments on commit e9588b6

Please sign in to comment.