Skip to content

Commit e9588b6

Browse files
committed
Fix fatal error if config/env does not exists
See #20
1 parent 888ffd7 commit e9588b6

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

src/Task/CopyDevPaths.php

+23-10
Original file line numberDiff line numberDiff line change
@@ -183,16 +183,7 @@ private function pathInfoForKey(string $key): array
183183
case Config::DEV_PATHS_PHP_CONFIG_DIR_KEY:
184184
$what = 'PHP config files';
185185
$target = $this->directories->phpConfigDir();
186-
if ($finder) {
187-
$finder = $finder->ignoreDotFiles(true)->exclude('env');
188-
$envs = Finder::create()
189-
->in("{$source}/env")
190-
->depth('== 0')
191-
->ignoreUnreadableDirs()
192-
->ignoreVCS(true)
193-
->ignoreDotFiles(true);
194-
$finder = $finder->append($envs);
195-
}
186+
$finder and $finder = $this->pathInfoForPhpConfigDir($finder, $source);
196187
break;
197188
case Config::DEV_PATHS_YAML_CONFIG_DIR_KEY:
198189
$what = 'Yaml config files';
@@ -217,6 +208,28 @@ static function (SplFileInfo $info): bool {
217208
return [$what, $source, $target, $finder];
218209
}
219210

211+
/**
212+
* @param Finder $finder
213+
* @param string $source
214+
* @return Finder
215+
*/
216+
private function pathInfoForPhpConfigDir(Finder $finder, string $source): Finder
217+
{
218+
$finder = $finder->ignoreDotFiles(true)->exclude('env');
219+
if (!is_dir("{$source}/env")) {
220+
return $finder;
221+
}
222+
223+
$envs = Finder::create()
224+
->in("{$source}/env")
225+
->depth('== 0')
226+
->ignoreUnreadableDirs()
227+
->ignoreVCS(true)
228+
->ignoreDotFiles(true);
229+
230+
return $finder->append($envs);
231+
}
232+
220233
/**
221234
* @param Io $io
222235
* @return int

0 commit comments

Comments
 (0)