Skip to content

Commit

Permalink
Update WorkbenchPlugin.php
Browse files Browse the repository at this point in the history
  • Loading branch information
tormjens authored Sep 19, 2024
1 parent adc5f63 commit cccee75
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Composer/WorkbenchPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public function uninstall(Composer $composer, IOInterface $io)
// TODO: Implement uninstall() method.
}

public function getHome()
{
return $_SERVER['HOME'] ?? (/*windows compatibility: */$_SERVER['HOMEDRIVE'] . $_SERVER['HOMEPATH']);
}

public function activate(Composer $composer, IOInterface $io)
{
$this->composer = $composer;
Expand All @@ -56,7 +61,7 @@ public static function getSubscribedEvents()

protected function createWorkbenchConfig()
{
if (!file_exists($workbenchConfigPath = $_SERVER['HOME'] . '/.composer/workbench.json')) {
if (!file_exists($workbenchConfigPath = $this->getHome() . '/.composer/workbench.json')) {
$filesystem = new Filesystem();

$filesystem->dumpFile($workbenchConfigPath, json_encode([
Expand All @@ -72,7 +77,7 @@ public function registerPackages()
return;
}

if (!file_exists($workbenchConfigPath = $_SERVER['HOME'] . '/.composer/workbench.json')) {
if (!file_exists($workbenchConfigPath = $this->getHome() . '/.composer/workbench.json')) {
return;
}

Expand Down Expand Up @@ -138,4 +143,4 @@ protected function installedPackages()

return $packages;
}
}
}

0 comments on commit cccee75

Please sign in to comment.