fix(cli): not show update avaialble messages when running gemini-cli locally (#4052)
This commit is contained in:
parent
ca07b5b0c4
commit
584a50a342
|
@ -20,6 +20,23 @@ vi.mock('update-notifier', () => ({
|
|||
describe('checkForUpdates', () => {
|
||||
beforeEach(() => {
|
||||
vi.resetAllMocks();
|
||||
// Clear DEV environment variable before each test
|
||||
delete process.env.DEV;
|
||||
});
|
||||
|
||||
it('should return null when running from source (DEV=true)', async () => {
|
||||
process.env.DEV = 'true';
|
||||
getPackageJson.mockResolvedValue({
|
||||
name: 'test-package',
|
||||
version: '1.0.0',
|
||||
});
|
||||
updateNotifier.mockReturnValue({
|
||||
update: { current: '1.0.0', latest: '1.1.0' },
|
||||
});
|
||||
const result = await checkForUpdates();
|
||||
expect(result).toBeNull();
|
||||
expect(getPackageJson).not.toHaveBeenCalled();
|
||||
expect(updateNotifier).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should return null if package.json is missing', async () => {
|
||||
|
|
|
@ -10,6 +10,11 @@ import { getPackageJson } from '../../utils/package.js';
|
|||
|
||||
export async function checkForUpdates(): Promise<string | null> {
|
||||
try {
|
||||
// Skip update check when running from source (development mode)
|
||||
if (process.env.DEV === 'true') {
|
||||
return null;
|
||||
}
|
||||
|
||||
const packageJson = await getPackageJson();
|
||||
if (!packageJson || !packageJson.name || !packageJson.version) {
|
||||
return null;
|
||||
|
|
Loading…
Reference in New Issue