-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathRecipeLoader.php
More file actions
45 lines (38 loc) · 1.07 KB
/
RecipeLoader.php
File metadata and controls
45 lines (38 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
namespace Hypernode\Deploy\Deployer;
use RuntimeException;
class RecipeLoader
{
public function load(string $recipe): void
{
$recipe = ltrim($recipe, DIRECTORY_SEPARATOR);
foreach ($this->getRecipePaths() as $path) {
$path = rtrim($path, DIRECTORY_SEPARATOR);
$file = $path . DIRECTORY_SEPARATOR . $recipe;
if (!is_readable($file)) {
continue;
}
/** @noinspection PhpIncludeInspection */
require $file;
return;
}
throw new RuntimeException(
sprintf(
'Recipe %s not found. Used include paths %s',
$recipe,
implode(', ', $this->getRecipePaths())
)
);
}
/**
* @return string[]
*/
private function getRecipePaths(): array
{
/** @psalm-suppress UndefinedConstant */
return [
APPLICATION_ROOT . '/vendor/deployer/deployer/recipe',
APPLICATION_ROOT . '/vendor/deployer/recipes/recipe',
];
}
}