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)
|
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')) {
|
if (!function_exists('exec')) {
|
||||||
return false;
|
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);
|
$command = escapeshellcmd($command);
|
||||||
|
|
||||||
// todo: find a better way (command could not be available)
|
exec($testCommand . $command, $output, $code);
|
||||||
exec('command -v '.$command, $output, $code);
|
|
||||||
|
|
||||||
return 0 === $code && count($output) > 0;
|
return 0 === $code && count($output) > 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user