add way to test command under windows
This commit is contained in:
parent
4fa9288fda
commit
85e77b14f7
|
@ -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;
|
||||
}
|
||||
|
|
Reference in New Issue