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:
Akhilesh Kumar
2026-05-21 17:08:35 +00:00
parent 8916cd742e
commit ddec6d5cb6
2 changed files with 10 additions and 12 deletions
@@ -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(() => {
+5 -7
View File
@@ -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> {