Skip to content

Commit

Permalink
add way to test command under windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ASA1-ET-JENKINS committed Aug 7, 2014
1 parent 4fa9288 commit 85e77b1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Symfony/Component/Finder/Shell/Shell.php
Expand Up @@ -50,19 +50,19 @@ public function getType()
*/
public function testCommand($command)
{
if (self::TYPE_WINDOWS === $this->type) {
// todo: find a way to test if Windows command exists
if (!function_exists('exec')) {
return false;
}

if (!function_exists('exec')) {
return false;
// todo: find a better way (command could not be available)
$testCommand = 'command -v ';
if (self::TYPE_WINDOWS === $this->type) {
$testCommand = 'where ';
}

$command = escapeshellcmd($command);

// todo: find a better way (command could not be available)
exec('command -v '.$command, $output, $code);
exec($testCommand . $command, $output, $code);

return 0 === $code && count($output) > 0;
}
Expand Down

0 comments on commit 85e77b1

Please sign in to comment.