mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 05:12:55 -07:00
fix: (some minor improvements to configs and getPackageJson return behaviour) (#12510)
Co-authored-by: Tommaso Sciortino <sciortino@gmail.com>
This commit is contained in:
committed by
GitHub
parent
f6ee025c46
commit
d53a5c4fb5
@@ -29,7 +29,6 @@ export default tseslint.config(
|
|||||||
// Global ignores
|
// Global ignores
|
||||||
ignores: [
|
ignores: [
|
||||||
'node_modules/*',
|
'node_modules/*',
|
||||||
'.integration-tests/**',
|
|
||||||
'eslint.config.js',
|
'eslint.config.js',
|
||||||
'packages/**/dist/**',
|
'packages/**/dist/**',
|
||||||
'bundle/**',
|
'bundle/**',
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import './src/gemini.js';
|
|
||||||
import { main } from './src/gemini.js';
|
import { main } from './src/gemini.js';
|
||||||
import { FatalError, writeToStderr } from '@google/gemini-cli-core';
|
import { FatalError, writeToStderr } from '@google/gemini-cli-core';
|
||||||
import { runExitCleanup } from './src/utils/cleanup.js';
|
import { runExitCleanup } from './src/utils/cleanup.js';
|
||||||
|
|||||||
@@ -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(
|
export async function getPackageJson(
|
||||||
cwd: string,
|
cwd: string,
|
||||||
): Promise<PackageJson | undefined> {
|
): Promise<PackageJson | undefined> {
|
||||||
const result = await readPackageUp({ cwd });
|
const result = await readPackageUp({ cwd });
|
||||||
if (!result) {
|
if (!result) {
|
||||||
// TODO: Maybe bubble this up as an error.
|
return undefined;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.packageJson;
|
return result.packageJson;
|
||||||
|
|||||||
Reference in New Issue
Block a user