mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-14 08:01:02 -07:00
Update error codes when process exiting the gemini cli (#13728)
This commit is contained in:
@@ -9,6 +9,7 @@ import { waitFor } from '../../test-utils/async.js';
|
||||
import { act } from 'react';
|
||||
import { vi } from 'vitest';
|
||||
import { FolderTrustDialog } from './FolderTrustDialog.js';
|
||||
import { ExitCodes } from '@google/gemini-cli-core';
|
||||
import * as processUtils from '../../utils/processUtils.js';
|
||||
|
||||
vi.mock('../../utils/processUtils.js', () => ({
|
||||
@@ -61,7 +62,9 @@ describe('FolderTrustDialog', () => {
|
||||
);
|
||||
});
|
||||
await waitFor(() => {
|
||||
expect(mockedExit).toHaveBeenCalledWith(1);
|
||||
expect(mockedExit).toHaveBeenCalledWith(
|
||||
ExitCodes.FATAL_CANCELLATION_ERROR,
|
||||
);
|
||||
});
|
||||
expect(onSelect).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -14,6 +14,8 @@ import { useKeypress } from '../hooks/useKeypress.js';
|
||||
import * as process from 'node:process';
|
||||
import * as path from 'node:path';
|
||||
import { relaunchApp } from '../../utils/processUtils.js';
|
||||
import { runExitCleanup } from '../../utils/cleanup.js';
|
||||
import { ExitCodes } from '@google/gemini-cli-core';
|
||||
|
||||
export enum FolderTrustChoice {
|
||||
TRUST_FOLDER = 'trust_folder',
|
||||
@@ -46,8 +48,9 @@ export const FolderTrustDialog: React.FC<FolderTrustDialogProps> = ({
|
||||
(key) => {
|
||||
if (key.name === 'escape') {
|
||||
setExiting(true);
|
||||
setTimeout(() => {
|
||||
process.exit(1);
|
||||
setTimeout(async () => {
|
||||
await runExitCleanup();
|
||||
process.exit(ExitCodes.FATAL_CANCELLATION_ERROR);
|
||||
}, 100);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -14,7 +14,7 @@ import { FolderTrustChoice } from '../components/FolderTrustDialog.js';
|
||||
import type { LoadedTrustedFolders } from '../../config/trustedFolders.js';
|
||||
import { TrustLevel } from '../../config/trustedFolders.js';
|
||||
import * as trustedFolders from '../../config/trustedFolders.js';
|
||||
import { coreEvents } from '@google/gemini-cli-core';
|
||||
import { coreEvents, ExitCodes } from '@google/gemini-cli-core';
|
||||
|
||||
const mockedCwd = vi.hoisted(() => vi.fn());
|
||||
const mockedExit = vi.hoisted(() => vi.fn());
|
||||
@@ -266,7 +266,7 @@ describe('useFolderTrust', () => {
|
||||
expect(result.current.isFolderTrustDialogOpen).toBe(false); // Dialog should close
|
||||
});
|
||||
|
||||
it('should emit feedback on failure to set value', () => {
|
||||
it('should emit feedback on failure to set value', async () => {
|
||||
isWorkspaceTrustedSpy.mockReturnValue({
|
||||
isTrusted: undefined,
|
||||
source: undefined,
|
||||
@@ -283,12 +283,12 @@ describe('useFolderTrust', () => {
|
||||
result.current.handleFolderTrustSelect(FolderTrustChoice.TRUST_FOLDER);
|
||||
});
|
||||
|
||||
vi.runAllTimers();
|
||||
await vi.runAllTimersAsync();
|
||||
|
||||
expect(emitFeedbackSpy).toHaveBeenCalledWith(
|
||||
'error',
|
||||
'Failed to save trust settings. Exiting Gemini CLI.',
|
||||
);
|
||||
expect(mockedExit).toHaveBeenCalledWith(1);
|
||||
expect(mockedExit).toHaveBeenCalledWith(ExitCodes.FATAL_CONFIG_ERROR);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14,7 +14,8 @@ import {
|
||||
} from '../../config/trustedFolders.js';
|
||||
import * as process from 'node:process';
|
||||
import { type HistoryItemWithoutId, MessageType } from '../types.js';
|
||||
import { coreEvents } from '@google/gemini-cli-core';
|
||||
import { coreEvents, ExitCodes } from '@google/gemini-cli-core';
|
||||
import { runExitCleanup } from '../../utils/cleanup.js';
|
||||
|
||||
export const useFolderTrust = (
|
||||
settings: LoadedSettings,
|
||||
@@ -75,8 +76,9 @@ export const useFolderTrust = (
|
||||
'error',
|
||||
'Failed to save trust settings. Exiting Gemini CLI.',
|
||||
);
|
||||
setTimeout(() => {
|
||||
process.exit(1);
|
||||
setTimeout(async () => {
|
||||
await runExitCleanup();
|
||||
process.exit(ExitCodes.FATAL_CONFIG_ERROR);
|
||||
}, 100);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user