Skip to content

Commit 6e912fb

Browse files
authored
Update CommandTool
1 parent fc61a3e commit 6e912fb

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/Utils/CommandTool

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,34 @@ class CommandTool
1414
public function __construct()
1515
{
1616
$this->executableFinder = new \Symfony\Component\Process\ExecutableFinder();
17+
18+
if (function_exists('base_path')) {
19+
$this->defaultExtraDirs = array_merge($this->defaultExtraDirs, [base_path()]);
20+
}
1721
}
1822

1923
public static function make()
2024
{
2125
return new static();
2226
}
2327

28+
public static function getRealpath($path)
29+
{
30+
return realpath($path);
31+
}
32+
2433
public function createProcess(array $command, string $cwd = null, array $env = null, $input = null, ?float $timeout = 60)
2534
{
2635
return tap(new \Symfony\Component\Process\Process(...func_get_args()));
2736
}
2837

29-
public function findBinary(string $name, array $extraDirs = [])
38+
public static function findBinary(string $name, array $extraDirs = [])
3039
{
31-
return $this->executableFinder->find($name, false, $this->defaultExtraDirs + $extraDirs);
40+
$instance = static::make();
41+
42+
$extraDirs = array_merge($instance->defaultExtraDirs, $extraDirs);
43+
44+
return $instance->executableFinder->find($name, null, $extraDirs);
3245
}
3346

3447
public static function getPhpProcess(array $argument)

0 commit comments

Comments
 (0)