doctor support windows base

This commit is contained in:
crazywhalecc
2023-12-23 00:23:47 +08:00
parent 201a31ce51
commit d85b9502fc
3 changed files with 19 additions and 7 deletions

View File

@@ -34,12 +34,23 @@ final class CheckListHandler
*/
public function emitFix(OutputInterface $output, CheckResult $result): void
{
pcntl_signal(SIGINT, function () use ($output) {
$output->writeln('<error>You cancelled fix</error>');
});
if (PHP_OS_FAMILY === 'Windows') {
sapi_windows_set_ctrl_handler(function () use ($output) {
$output->writeln('<error>You cancelled fix</error>');
});
} elseif (extension_loaded('pcntl')) {
pcntl_signal(SIGINT, function () use ($output) {
$output->writeln('<error>You cancelled fix</error>');
});
}
$fix_result = call_user_func($this->fix_map[$result->getFixItem()], ...$result->getFixParams());
pcntl_signal(SIGINT, SIG_IGN);
if (PHP_OS_FAMILY === 'Windows') {
sapi_windows_set_ctrl_handler(null);
} elseif (extension_loaded('pcntl')) {
pcntl_signal(SIGINT, SIG_IGN);
}
if ($fix_result) {
$output->writeln('<info>Fix done</info>');