mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-06-24 18:27:01 -07:00
refactor(core): use global normalizePath in ProjectRegistry
Address code review comments by using normalizePath and resolveToRealPath from paths.ts for consistency and robustness.
This commit is contained in:
@@ -13,6 +13,10 @@ import * as path from 'node:path';
|
||||
import * as os from 'node:os';
|
||||
import { ProjectRegistry } from './projectRegistry.js';
|
||||
import { lock } from 'proper-lockfile';
|
||||
import {
|
||||
normalizePath as normalizePathUtil,
|
||||
resolveToRealPath,
|
||||
} from '../utils/paths.js';
|
||||
|
||||
vi.mock('proper-lockfile');
|
||||
|
||||
@@ -23,11 +27,7 @@ describe('ProjectRegistry', () => {
|
||||
let baseDir2: string;
|
||||
|
||||
function normalizePath(p: string): string {
|
||||
let resolved = path.resolve(p);
|
||||
if (os.platform() === 'win32') {
|
||||
resolved = resolved.toLowerCase();
|
||||
}
|
||||
return resolved;
|
||||
return normalizePathUtil(resolveToRealPath(p));
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -7,12 +7,14 @@
|
||||
import { randomUUID } from 'node:crypto';
|
||||
import * as fs from 'node:fs';
|
||||
import * as path from 'node:path';
|
||||
import * as os from 'node:os';
|
||||
import { lock } from 'proper-lockfile';
|
||||
import { z } from 'zod';
|
||||
import { debugLogger } from '../utils/debugLogger.js';
|
||||
import { isNodeError } from '../utils/errors.js';
|
||||
import { resolveToRealPath } from '../utils/paths.js';
|
||||
import {
|
||||
normalizePath as normalizePathUtil,
|
||||
resolveToRealPath,
|
||||
} from '../utils/paths.js';
|
||||
|
||||
export interface RegistryData {
|
||||
projects: Record<string, string>;
|
||||
@@ -94,11 +96,7 @@ export class ProjectRegistry {
|
||||
}
|
||||
|
||||
private normalizePath(projectPath: string): string {
|
||||
let resolved = resolveToRealPath(projectPath);
|
||||
if (os.platform() === 'win32') {
|
||||
resolved = resolved.toLowerCase();
|
||||
}
|
||||
return resolved;
|
||||
return normalizePathUtil(resolveToRealPath(projectPath));
|
||||
}
|
||||
|
||||
private async save(data: RegistryData): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user