diff options
| author | christine betts <[email protected]> | 2025-07-21 20:14:07 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-21 20:14:07 +0000 |
| commit | f95674e6464659d6f8050215261d96ec44ea2fb1 (patch) | |
| tree | d9419b845d0c87238dd043560c21911afd25766e /packages/cli/src/config/settings.ts | |
| parent | 74d0f4c79fbc035804c80b6f594d42dcb466572a (diff) | |
Add env var to configure system settings path (#4339)
Diffstat (limited to 'packages/cli/src/config/settings.ts')
| -rw-r--r-- | packages/cli/src/config/settings.ts | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/packages/cli/src/config/settings.ts b/packages/cli/src/config/settings.ts index 3cbfe22d..bc2206a7 100644 --- a/packages/cli/src/config/settings.ts +++ b/packages/cli/src/config/settings.ts @@ -25,7 +25,10 @@ export const SETTINGS_DIRECTORY_NAME = '.gemini'; export const USER_SETTINGS_DIR = path.join(homedir(), SETTINGS_DIRECTORY_NAME); export const USER_SETTINGS_PATH = path.join(USER_SETTINGS_DIR, 'settings.json'); -function getSystemSettingsPath(): string { +export function getSystemSettingsPath(): string { + if (process.env.GEMINI_CLI_SYSTEM_SETTINGS_PATH) { + return process.env.GEMINI_CLI_SYSTEM_SETTINGS_PATH; + } if (platform() === 'darwin') { return '/Library/Application Support/GeminiCli/settings.json'; } else if (platform() === 'win32') { @@ -35,8 +38,6 @@ function getSystemSettingsPath(): string { } } -export const SYSTEM_SETTINGS_PATH = getSystemSettingsPath(); - export enum SettingScope { User = 'User', Workspace = 'Workspace', @@ -297,11 +298,11 @@ export function loadSettings(workspaceDir: string): LoadedSettings { let userSettings: Settings = {}; let workspaceSettings: Settings = {}; const settingsErrors: SettingsError[] = []; - + const systemSettingsPath = getSystemSettingsPath(); // Load system settings try { - if (fs.existsSync(SYSTEM_SETTINGS_PATH)) { - const systemContent = fs.readFileSync(SYSTEM_SETTINGS_PATH, 'utf-8'); + if (fs.existsSync(systemSettingsPath)) { + const systemContent = fs.readFileSync(systemSettingsPath, 'utf-8'); const parsedSystemSettings = JSON.parse( stripJsonComments(systemContent), ) as Settings; @@ -310,7 +311,7 @@ export function loadSettings(workspaceDir: string): LoadedSettings { } catch (error: unknown) { settingsErrors.push({ message: getErrorMessage(error), - path: SYSTEM_SETTINGS_PATH, + path: systemSettingsPath, }); } @@ -368,7 +369,7 @@ export function loadSettings(workspaceDir: string): LoadedSettings { return new LoadedSettings( { - path: SYSTEM_SETTINGS_PATH, + path: systemSettingsPath, settings: systemSettings, }, { |
