From ddec6d5cb65c3db4ba74a4f497e4807f7ee38c8d Mon Sep 17 00:00:00 2001 From: Akhilesh Kumar Date: Thu, 21 May 2026 17:08:35 +0000 Subject: [PATCH] refactor(core): use global normalizePath in ProjectRegistry Address code review comments by using normalizePath and resolveToRealPath from paths.ts for consistency and robustness. --- packages/core/src/config/projectRegistry.test.ts | 10 +++++----- packages/core/src/config/projectRegistry.ts | 12 +++++------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/packages/core/src/config/projectRegistry.test.ts b/packages/core/src/config/projectRegistry.test.ts index d3201133a6..26716eb6f6 100644 --- a/packages/core/src/config/projectRegistry.test.ts +++ b/packages/core/src/config/projectRegistry.test.ts @@ -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(() => { diff --git a/packages/core/src/config/projectRegistry.ts b/packages/core/src/config/projectRegistry.ts index b50ee61cc2..885aab9cf8 100644 --- a/packages/core/src/config/projectRegistry.ts +++ b/packages/core/src/config/projectRegistry.ts @@ -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; @@ -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 {