Skip to content

Commit 915f190

Browse files
committed
refactor(ConfigClient): prioritize APPDATA env on USERPROFILE for Windows in default config path resolving
1 parent 0bceb35 commit 915f190

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/Common/EnvConfig/ConfigClient.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -221,17 +221,22 @@ private static function normalizeProfileNames(array $profiles): array
221221
*/
222222
private static function getDefaultConfigPath(array $env): ?string
223223
{
224-
$home = $env['HOME'] ?? $env['USERPROFILE'] ?? null;
225-
if ($home === null) {
226-
return null;
224+
// Check APPDATA for Windows first
225+
$configDir = $env['APPDATA'] ?? null;
226+
227+
if ($configDir === null) {
228+
$home = $env['HOME'] ?? $env['USERPROFILE'] ?? null;
229+
if ($home === null) {
230+
return null;
231+
}
232+
233+
$configDir = match (\PHP_OS_FAMILY) {
234+
'Windows' => $home . '\\AppData\\Roaming',
235+
'Darwin' => $home . '/Library/Application Support',
236+
default => $env['XDG_CONFIG_HOME'] ?? ($home . '/.config'),
237+
};
227238
}
228239

229-
$configDir = match (\PHP_OS_FAMILY) {
230-
'Windows' => $env['APPDATA'] ?? ($home . '\\AppData\\Roaming'),
231-
'Darwin' => $home . '/Library/Application Support',
232-
default => $env['XDG_CONFIG_HOME'] ?? ($home . '/.config'),
233-
};
234-
235240
return $configDir . \DIRECTORY_SEPARATOR . 'temporalio' . \DIRECTORY_SEPARATOR . 'temporal.toml';
236241
}
237242
}

0 commit comments

Comments
 (0)