From d53a5c4fb5d2ede12524771a1756cbee827aee6b Mon Sep 17 00:00:00 2001 From: grMLEqomlkkU5Eeinz4brIrOVCUCkJuN <209283286+grMLEqomlkkU5Eeinz4brIrOVCUCkJuN@users.noreply.github.com> Date: Tue, 25 Nov 2025 05:20:23 +0800 Subject: [PATCH] fix: (some minor improvements to configs and getPackageJson return behaviour) (#12510) Co-authored-by: Tommaso Sciortino --- eslint.config.js | 1 - packages/cli/index.ts | 1 - packages/core/src/utils/package.ts | 17 +++++++++++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 1a1b5652d4..1d688139ca 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -29,7 +29,6 @@ export default tseslint.config( // Global ignores ignores: [ 'node_modules/*', - '.integration-tests/**', 'eslint.config.js', 'packages/**/dist/**', 'bundle/**', diff --git a/packages/cli/index.ts b/packages/cli/index.ts index 894b5c1fd4..b2bc5ca9e3 100644 --- a/packages/cli/index.ts +++ b/packages/cli/index.ts @@ -6,7 +6,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -import './src/gemini.js'; import { main } from './src/gemini.js'; import { FatalError, writeToStderr } from '@google/gemini-cli-core'; import { runExitCleanup } from './src/utils/cleanup.js'; diff --git a/packages/core/src/utils/package.ts b/packages/core/src/utils/package.ts index 0ef7673f5d..81b208bc5f 100644 --- a/packages/core/src/utils/package.ts +++ b/packages/core/src/utils/package.ts @@ -15,13 +15,26 @@ export type PackageJson = BasePackageJson & { }; }; +/** + * Reads package.json from the current directory or any parent directory. + * + * @param cwd - The directory to start searching from (searches upward to filesystem root) + * @returns The package.json object if found, or `undefined` if no package.json exists + * in the directory hierarchy. This is expected behavior when called from + * directories outside of a Node.js project. + * + * @example + * ```ts + * const pkg = await getPackageJson(__dirname); + * const version = pkg?.version ?? 'unknown'; + * ``` + */ export async function getPackageJson( cwd: string, ): Promise { const result = await readPackageUp({ cwd }); if (!result) { - // TODO: Maybe bubble this up as an error. - return; + return undefined; } return result.packageJson;