mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-14 05:42:54 -07:00
Fix missing slash commands when Gemini CLI is in a project with a package.json that doesn't follow semantic versioning (#17561)
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
readPackageUp,
|
||||
type PackageJson as BasePackageJson,
|
||||
} from 'read-package-up';
|
||||
import { debugLogger } from './debugLogger.js';
|
||||
|
||||
export type PackageJson = BasePackageJson & {
|
||||
config?: {
|
||||
@@ -32,10 +33,15 @@ export type PackageJson = BasePackageJson & {
|
||||
export async function getPackageJson(
|
||||
cwd: string,
|
||||
): Promise<PackageJson | undefined> {
|
||||
const result = await readPackageUp({ cwd });
|
||||
if (!result) {
|
||||
try {
|
||||
const result = await readPackageUp({ cwd, normalize: false });
|
||||
if (!result) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return result.packageJson;
|
||||
} catch (error) {
|
||||
debugLogger.error('Error occurred while reading package.json', error);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return result.packageJson;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user