mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-10 22:21:22 -07:00
fix(core): Use shell for spawn on Windows (#9995)
This commit is contained in:
@@ -32,13 +32,25 @@ class MockProcessExitError extends Error {
|
||||
}
|
||||
|
||||
// Mock dependencies
|
||||
vi.mock('./config/settings.js', async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import('./config/settings.js')>();
|
||||
return {
|
||||
...actual,
|
||||
loadSettings: vi.fn(),
|
||||
};
|
||||
});
|
||||
vi.mock('./config/settings.js', () => ({
|
||||
loadSettings: vi.fn().mockReturnValue({
|
||||
merged: {
|
||||
advanced: {},
|
||||
security: { auth: {} },
|
||||
ui: {},
|
||||
},
|
||||
setValue: vi.fn(),
|
||||
forScope: () => ({ settings: {}, originalSettings: {}, path: '' }),
|
||||
errors: [],
|
||||
}),
|
||||
migrateDeprecatedSettings: vi.fn(),
|
||||
SettingScope: {
|
||||
User: 'user',
|
||||
Workspace: 'workspace',
|
||||
System: 'system',
|
||||
SystemDefaults: 'system-defaults',
|
||||
},
|
||||
}));
|
||||
|
||||
vi.mock('./config/config.js', () => ({
|
||||
loadCliConfig: vi.fn().mockResolvedValue({
|
||||
|
||||
@@ -31,6 +31,7 @@ describe('validateNonInterActiveAuth', () => {
|
||||
processExitSpy = vi.spyOn(process, 'exit').mockImplementation((code) => {
|
||||
throw new Error(`process.exit(${code}) called`);
|
||||
});
|
||||
vi.spyOn(auth, 'validateAuthMethod').mockReturnValue(null);
|
||||
refreshAuthMock = vi.fn().mockResolvedValue('refreshed');
|
||||
mockSettings = {
|
||||
system: { path: '', settings: {} },
|
||||
|
||||
@@ -119,7 +119,24 @@ describe('ide-installer', () => {
|
||||
'google.gemini-cli-vscode-ide-companion',
|
||||
'--force',
|
||||
],
|
||||
{ stdio: 'pipe' },
|
||||
{ stdio: 'pipe', shell: false },
|
||||
);
|
||||
});
|
||||
|
||||
it('installs the extension using code cli on windows', async () => {
|
||||
const { installer } = setup({
|
||||
platform: 'win32',
|
||||
execSync: () => 'C:\\Program Files\\Microsoft VS Code\\bin\\code.cmd',
|
||||
});
|
||||
await installer.install();
|
||||
expect(child_process.spawnSync).toHaveBeenCalledWith(
|
||||
'C:\\Program Files\\Microsoft VS Code\\bin\\code.cmd',
|
||||
[
|
||||
'--install-extension',
|
||||
'google.gemini-cli-vscode-ide-companion',
|
||||
'--force',
|
||||
],
|
||||
{ stdio: 'pipe', shell: true },
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ class VsCodeInstaller implements IdeInstaller {
|
||||
'google.gemini-cli-vscode-ide-companion',
|
||||
'--force',
|
||||
],
|
||||
{ stdio: 'pipe' },
|
||||
{ stdio: 'pipe', shell: this.platform === 'win32' },
|
||||
);
|
||||
|
||||
if (result.status !== 0) {
|
||||
|
||||
@@ -339,6 +339,7 @@ describe('editor utils', () => {
|
||||
diffCommand.args,
|
||||
{
|
||||
stdio: 'inherit',
|
||||
shell: process.platform === 'win32',
|
||||
},
|
||||
);
|
||||
expect(mockSpawnOn).toHaveBeenCalledWith('close', expect.any(Function));
|
||||
|
||||
@@ -195,6 +195,7 @@ export async function openDiff(
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
const childProcess = spawn(diffCommand.command, diffCommand.args, {
|
||||
stdio: 'inherit',
|
||||
shell: process.platform === 'win32',
|
||||
});
|
||||
|
||||
childProcess.on('close', (code) => {
|
||||
|
||||
Reference in New Issue
Block a user