Skip to content

Commit e660ba6

Browse files
authored
Fix the bug that cannot work in vscode extensions (#5779)
1 parent d5c5d04 commit e660ba6

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

co-phpunit

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,26 @@ if (isset($options['prepend'])) {
5050
require $options['prepend'];
5151
}
5252
unset($options);
53+
if (!isset(getopt('', ['prepend:'])['prepend'])) {
54+
(function () {
55+
$prepend = null;
56+
foreach ($_SERVER['argv'] as $index => $argv) {
57+
// --prepend /path/to/file
58+
if ($argv === '--prepend') {
59+
$prepend = $_SERVER['argv'][$index + 1] ?? null;
60+
break;
61+
}
62+
// --prepend=/path/to/file
63+
if (strpos($argv, '--prepend=') === 0) {
64+
$prepend = substr($argv, 10);
65+
break;
66+
}
67+
}
68+
if ($prepend !== null && file_exists($prepend)) {
69+
require $prepend;
70+
}
71+
})();
72+
}
5373
require PHPUNIT_COMPOSER_INSTALL;
5474
$code = 0;
5575
Swoole\Coroutine::set(['hook_flags' => SWOOLE_HOOK_ALL, 'exit_condition' => function () {

0 commit comments

Comments
 (0)