Skip to content

Commit

Permalink
Merge pull request #14 from tourze/patch-2
Browse files Browse the repository at this point in the history
fix package_installed 判断错误
  • Loading branch information
chaz6chez authored Oct 9, 2024
2 parents 409b12c + 487a57b commit 46410ca
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Workbunny\WebmanCoroutine;

// 设置环境变量
use Composer\InstalledVersions;
use Workbunny\WebmanCoroutine\Handlers\HandlerInterface;

putenv('WORKBUNNY_COROUTINE=1');
Expand Down Expand Up @@ -53,13 +54,7 @@ function wait_for(?\Closure $closure, float|int $timeout = -1): void
*/
function package_installed(string $packageName): bool
{
$composerFile = dirname(__DIR__) . '/composer.json';
if (!file_exists($composerFile)) {
return false;
}
$composerData = json_decode(file_get_contents($composerFile), true);

return isset($composerData['require'][$packageName]);
return InstalledVersions::isInstalled($packageName);
}

/**
Expand Down

0 comments on commit 46410ca

Please sign in to comment.