Skip to content

Commit

Permalink
Merge pull request #51 from wkhayrattee/main
Browse files Browse the repository at this point in the history
fix: on macOS if Herd is installed, adjust the valet config file path accordingly
  • Loading branch information
stevebauman authored May 30, 2024
2 parents 4f99064 + c35e5b2 commit 1cb8ddc
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions src/scripts/global-ray-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,33 @@ public static function isRunningInLaravelAwareApp()

public static function getComposerPath()
{
$composerJson = getcwd() . '/composer.json';
$composerPath = getcwd() . '/composer.json';

if (strpos($composerJson, 'valet') !== false) {
$valetConfig = json_decode(file_get_contents($_SERVER['HOME'].'/.config/valet/config.json'));
if (strpos($composerPath, 'valet') === false) {
return $composerPath;
}

foreach ($valetConfig->paths as $path) {
$composerPath = $path . '/' . str_replace('.' . $valetConfig->tld, '/', $_SERVER['HTTP_HOST']) . 'composer.json';
$valetConfig = json_decode(
file_get_contents(static::getConfigPath())
);

if (file_exists($composerPath)) {
return $composerPath;
}
foreach ($valetConfig->paths as $path) {
$projectComposerPath = $path . '/' . str_replace('.' . $valetConfig->tld, '/', $_SERVER['HTTP_HOST']) . 'composer.json';

if (file_exists($projectComposerPath)) {
return $projectComposerPath;
}
}

return $composerJson;
return $composerPath;
}

public static function getConfigPath()
{
$valetConfigPath = $_SERVER['HOME'] . '/.config/valet/config.json';
$herdConfigPath = $_SERVER['HOME'] . '/Library/Application Support/Herd/config/valet/config.json';

return file_exists($herdConfigPath) ? $herdConfigPath : $valetConfigPath;
}
}

Expand Down

0 comments on commit 1cb8ddc

Please sign in to comment.