GrumPHP\Locator\ExternalCommand::locate PHP 메소드

locate() 공개 메소드

public locate ( string $command, boolean $forceUnix = false ) : string
$command string
$forceUnix boolean This parameter makes it possible to force unix style commands on a windows environment. This can be useful in git hooks.
리턴 string
    public function locate($command, $forceUnix = false)
    {
        // Search executable:
        $executable = $this->executableFinder->find($command, null, [$this->binDir]);
        if (!$executable) {
            throw new RuntimeException(sprintf('The executable for "%s" could not be found.', $command));
        }
        // Make sure to add unix-style directory separators if unix-mode is enforced
        if ($forceUnix) {
            $parts = pathinfo($executable);
            $executable = $parts['dirname'] . '/' . $parts['filename'];
        }
        return $executable;
    }

Usage Example

예제 #1
0
 function it_should_be_able_to_create_process_arguments_based_on_taskname(ExternalCommand $externalCommandLocator)
 {
     $externalCommandLocator->locate('grumphp')->willReturn('/usr/bin/grumphp');
     $arguments = $this->createArgumentsForCommand('grumphp');
     $arguments->shouldHaveType('GrumPHP\\Collection\\ProcessArgumentsCollection');
     $arguments[0]->shouldBe('/usr/bin/grumphp');
     $arguments->count()->shouldBe(1);
 }
All Usage Examples Of GrumPHP\Locator\ExternalCommand::locate
ExternalCommand