mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 05:12:55 -07:00
address feedback
This commit is contained in:
@@ -22,14 +22,14 @@ describe('getPackageJson', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return packageJson when found', async () => {
|
it('should return packageJson when found', async () => {
|
||||||
const mockPackageJson = { name: 'test-pkg', version: '1.2.3' };
|
const expectedPackageJsonResult = { name: 'test-pkg', version: '1.2.3' };
|
||||||
vi.mocked(readPackageUp).mockResolvedValue({
|
vi.mocked(readPackageUp).mockResolvedValue({
|
||||||
packageJson: mockPackageJson,
|
packageJson: expectedPackageJsonResult,
|
||||||
path: '/path/to/package.json',
|
path: '/path/to/package.json',
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = await getPackageJson('/some/path');
|
const result = await getPackageJson('/some/path');
|
||||||
expect(result).toEqual(mockPackageJson);
|
expect(result).toEqual(expectedPackageJsonResult);
|
||||||
expect(readPackageUp).toHaveBeenCalledWith({
|
expect(readPackageUp).toHaveBeenCalledWith({
|
||||||
cwd: '/some/path',
|
cwd: '/some/path',
|
||||||
normalize: false,
|
normalize: false,
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
readPackageUp,
|
readPackageUp,
|
||||||
type PackageJson as BasePackageJson,
|
type PackageJson as BasePackageJson,
|
||||||
} from 'read-package-up';
|
} from 'read-package-up';
|
||||||
|
import { debugLogger } from './debugLogger.js';
|
||||||
|
|
||||||
export type PackageJson = BasePackageJson & {
|
export type PackageJson = BasePackageJson & {
|
||||||
config?: {
|
config?: {
|
||||||
@@ -39,7 +40,8 @@ export async function getPackageJson(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return result.packageJson;
|
return result.packageJson;
|
||||||
} catch (_error) {
|
} catch (error) {
|
||||||
|
debugLogger.error('Error occurred while reading package.json', error);
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user