fix(cli): not show update avaialble messages when running gemini-cli locally (#4052)

This commit is contained in:
Yuki Okita 2025-07-18 09:44:45 +09:00 committed by GitHub
parent ca07b5b0c4
commit 584a50a342
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 0 deletions

View File

@ -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 () => {

View File

@ -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;