mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
Improved git hash handling, add dirty git detection and disable automatic reporting for dirty builds
This commit is contained in:
@ -492,4 +492,36 @@ class Utils{
|
||||
}
|
||||
return $hash;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $command Command to execute
|
||||
* @param string|null &$stdout Reference parameter to write stdout to
|
||||
* @param string|null &$stderr Reference parameter to write stderr to
|
||||
*
|
||||
* @return int process exit code
|
||||
*/
|
||||
public static function execute(string $command, string &$stdout = null, string &$stderr = null) : int{
|
||||
$process = proc_open($command, [
|
||||
["pipe", "r"],
|
||||
["pipe", "w"],
|
||||
["pipe", "w"]
|
||||
], $pipes);
|
||||
|
||||
if($process === false){
|
||||
$stderr = "Failed to open process";
|
||||
$stdout = "";
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
$stdout = stream_get_contents($pipes[1]);
|
||||
$stderr = stream_get_contents($pipes[2]);
|
||||
|
||||
foreach($pipes as $p){
|
||||
fclose($p);
|
||||
}
|
||||
|
||||
return proc_close($process);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user