diff --git a/src/core/runtime/runtime-environment.ts b/src/core/runtime/runtime-environment.ts index 88b1ca5..38a81d6 100644 --- a/src/core/runtime/runtime-environment.ts +++ b/src/core/runtime/runtime-environment.ts @@ -23,13 +23,20 @@ function shellQuote(value: string): string { return `'${value.replace(/'/g, `'"'"'`)}'`; } +function preserveToolConfigDir(envKey: string, xdgSubdir: string): string { + return process.env[envKey] + ?? join(process.env['XDG_CONFIG_HOME'] ?? join(process.env['HOME']!, '.config'), xdgSubdir); +} + function createBaseEnvironment(runtimeRoot: string): Record { + const ghConfigDir = preserveToolConfigDir('GH_CONFIG_DIR', 'gh'); return { TMPDIR: join(runtimeRoot, 'tmp'), XDG_CACHE_HOME: join(runtimeRoot, 'cache'), XDG_CONFIG_HOME: join(runtimeRoot, 'config'), XDG_STATE_HOME: join(runtimeRoot, 'state'), CI: 'true', + GH_CONFIG_DIR: ghConfigDir, }; }