mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-18 01:51:20 -07:00
Introduce GEMINI_CLI_HOME for strict test isolation (#15907)
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
import path from 'node:path';
|
||||
import os from 'node:os';
|
||||
import process from 'node:process';
|
||||
import * as crypto from 'node:crypto';
|
||||
|
||||
export const GEMINI_DIR = '.gemini';
|
||||
@@ -18,13 +19,33 @@ export const GOOGLE_ACCOUNTS_FILENAME = 'google_accounts.json';
|
||||
*/
|
||||
export const SHELL_SPECIAL_CHARS = /[ \t()[\]{};|*?$`'"#&<>!~]/;
|
||||
|
||||
/**
|
||||
* Returns the home directory.
|
||||
* If GEMINI_CLI_HOME environment variable is set, it returns its value.
|
||||
* Otherwise, it returns the user's home directory.
|
||||
*/
|
||||
export function homedir(): string {
|
||||
const envHome = process.env['GEMINI_CLI_HOME'];
|
||||
if (envHome) {
|
||||
return envHome;
|
||||
}
|
||||
return os.homedir();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the operating system's default directory for temporary files.
|
||||
*/
|
||||
export function tmpdir(): string {
|
||||
return os.tmpdir();
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the home directory with a tilde.
|
||||
* @param path - The path to tildeify.
|
||||
* @returns The tildeified path.
|
||||
*/
|
||||
export function tildeifyPath(path: string): string {
|
||||
const homeDir = os.homedir();
|
||||
const homeDir = homedir();
|
||||
if (path.startsWith(homeDir)) {
|
||||
return path.replace(homeDir, '~');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user