Add support for @php <abs path to binary from PATH>, fixes #9726
parent
d0b399b788
commit
bcd862c3dc
|
@ -26,6 +26,7 @@ use Composer\Util\ProcessExecutor;
|
|||
use Composer\Script\Event as ScriptEvent;
|
||||
use Composer\ClassLoader;
|
||||
use Symfony\Component\Process\PhpExecutableFinder;
|
||||
use Symfony\Component\Process\ExecutableFinder;
|
||||
|
||||
/**
|
||||
* The Event Dispatcher.
|
||||
|
@ -258,6 +259,15 @@ class EventDispatcher
|
|||
return str_replace('/', '\\', $path[0]);
|
||||
}, $pathAndArgs);
|
||||
}
|
||||
// match somename (not in quote, and not a qualified path) and if it is not a valid path from CWD then try to find it
|
||||
// in $PATH. This allows support for `@php foo` where foo is a binary name found in PATH but not an actual relative path
|
||||
preg_match('{^[^\'"\s/\\\\]+}', $pathAndArgs, $match);
|
||||
if (!file_exists($match[0])) {
|
||||
$finder = new ExecutableFinder;
|
||||
if ($pathToExec = $finder->find($match[0])) {
|
||||
$pathAndArgs = $pathToExec . substr($pathAndArgs, strlen($match[0]));
|
||||
}
|
||||
}
|
||||
$exec = $this->getPhpExecCommand() . ' ' . $pathAndArgs;
|
||||
} else {
|
||||
$finder = new PhpExecutableFinder();
|
||||
|
|
Loading…
Reference in New Issue