add way to test command under windows

This commit is contained in:
Gordon Franke 2014-08-07 09:02:32 +02:00
parent 4fa9288fda
commit 85e77b14f7
1 changed files with 7 additions and 7 deletions

View File

@ -50,19 +50,19 @@ class Shell
*/
public function testCommand($command)
{
if (self::TYPE_WINDOWS === $this->type) {
// todo: find a way to test if Windows command exists
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;
}