mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-12 12:54:07 -07:00
committed by
GitHub
parent
6d3437badb
commit
20aa695ac4
+5
-21
@@ -6,19 +6,12 @@
|
|||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// --- Fast Path for Version ---
|
import { main } from './src/gemini.js';
|
||||||
// We check for version flags at the very top to avoid loading any heavy dependencies.
|
import { FatalError, writeToStderr } from '@google/gemini-cli-core';
|
||||||
// process.env.CLI_VERSION is defined during the build process by esbuild.
|
import { runExitCleanup } from './src/utils/cleanup.js';
|
||||||
if (process.argv.includes('--version') || process.argv.includes('-v')) {
|
|
||||||
console.log(process.env['CLI_VERSION'] || 'unknown');
|
|
||||||
process.exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Global Entry Point ---
|
// --- Global Entry Point ---
|
||||||
|
|
||||||
let writeToStderrFn: (message: string) => void = (msg) =>
|
|
||||||
process.stderr.write(msg);
|
|
||||||
|
|
||||||
// Suppress known race condition error in node-pty on Windows
|
// Suppress known race condition error in node-pty on Windows
|
||||||
// Tracking bug: https://github.com/microsoft/node-pty/issues/827
|
// Tracking bug: https://github.com/microsoft/node-pty/issues/827
|
||||||
process.on('uncaughtException', (error) => {
|
process.on('uncaughtException', (error) => {
|
||||||
@@ -35,22 +28,13 @@ process.on('uncaughtException', (error) => {
|
|||||||
// For other errors, we rely on the default behavior, but since we attached a listener,
|
// For other errors, we rely on the default behavior, but since we attached a listener,
|
||||||
// we must manually replicate it.
|
// we must manually replicate it.
|
||||||
if (error instanceof Error) {
|
if (error instanceof Error) {
|
||||||
writeToStderrFn(error.stack + '\n');
|
writeToStderr(error.stack + '\n');
|
||||||
} else {
|
} else {
|
||||||
writeToStderrFn(String(error) + '\n');
|
writeToStderr(String(error) + '\n');
|
||||||
}
|
}
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
const [{ main }, { FatalError, writeToStderr }, { runExitCleanup }] =
|
|
||||||
await Promise.all([
|
|
||||||
import('./src/gemini.js'),
|
|
||||||
import('@google/gemini-cli-core'),
|
|
||||||
import('./src/utils/cleanup.js'),
|
|
||||||
]);
|
|
||||||
|
|
||||||
writeToStderrFn = writeToStderr;
|
|
||||||
|
|
||||||
main().catch(async (error) => {
|
main().catch(async (error) => {
|
||||||
// Set a timeout to force exit if cleanup hangs
|
// Set a timeout to force exit if cleanup hangs
|
||||||
const cleanupTimeout = setTimeout(() => {
|
const cleanupTimeout = setTimeout(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user