mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 05:12:55 -07:00
fix(cli): correctly handle auto-update for standalone binaries (#23038)
This commit is contained in:
@@ -202,7 +202,12 @@ describe('handleAutoUpdate', () => {
|
|||||||
expect(mockSpawn).not.toHaveBeenCalled();
|
expect(mockSpawn).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it.each([PackageManager.NPX, PackageManager.PNPX, PackageManager.BUNX])(
|
it.each([
|
||||||
|
PackageManager.NPX,
|
||||||
|
PackageManager.PNPX,
|
||||||
|
PackageManager.BUNX,
|
||||||
|
PackageManager.BINARY,
|
||||||
|
])(
|
||||||
'should suppress update notifications when running via %s',
|
'should suppress update notifications when running via %s',
|
||||||
(packageManager) => {
|
(packageManager) => {
|
||||||
mockGetInstallationInfo.mockReturnValue({
|
mockGetInstallationInfo.mockReturnValue({
|
||||||
|
|||||||
@@ -87,9 +87,12 @@ export function handleAutoUpdate(
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
[PackageManager.NPX, PackageManager.PNPX, PackageManager.BUNX].includes(
|
[
|
||||||
installationInfo.packageManager,
|
PackageManager.NPX,
|
||||||
)
|
PackageManager.PNPX,
|
||||||
|
PackageManager.BUNX,
|
||||||
|
PackageManager.BINARY,
|
||||||
|
].includes(installationInfo.packageManager)
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,6 +58,19 @@ describe('getInstallationInfo', () => {
|
|||||||
process.argv = originalArgv;
|
process.argv = originalArgv;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should detect running as a standalone binary', () => {
|
||||||
|
vi.stubEnv('IS_BINARY', 'true');
|
||||||
|
process.argv[1] = '/path/to/binary';
|
||||||
|
const info = getInstallationInfo(projectRoot, true);
|
||||||
|
expect(info.packageManager).toBe(PackageManager.BINARY);
|
||||||
|
expect(info.isGlobal).toBe(true);
|
||||||
|
expect(info.updateMessage).toBe(
|
||||||
|
'Running as a standalone binary. Please update by downloading the latest version from GitHub.',
|
||||||
|
);
|
||||||
|
expect(info.updateCommand).toBeUndefined();
|
||||||
|
vi.unstubAllEnvs();
|
||||||
|
});
|
||||||
|
|
||||||
it('should return UNKNOWN when cliPath is not available', () => {
|
it('should return UNKNOWN when cliPath is not available', () => {
|
||||||
process.argv[1] = '';
|
process.argv[1] = '';
|
||||||
const info = getInstallationInfo(projectRoot, true);
|
const info = getInstallationInfo(projectRoot, true);
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ export enum PackageManager {
|
|||||||
BUNX = 'bunx',
|
BUNX = 'bunx',
|
||||||
HOMEBREW = 'homebrew',
|
HOMEBREW = 'homebrew',
|
||||||
NPX = 'npx',
|
NPX = 'npx',
|
||||||
|
BINARY = 'binary',
|
||||||
UNKNOWN = 'unknown',
|
UNKNOWN = 'unknown',
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,6 +42,16 @@ export function getInstallationInfo(
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Check for standalone binary first
|
||||||
|
if (process.env['IS_BINARY'] === 'true') {
|
||||||
|
return {
|
||||||
|
packageManager: PackageManager.BINARY,
|
||||||
|
isGlobal: true,
|
||||||
|
updateMessage:
|
||||||
|
'Running as a standalone binary. Please update by downloading the latest version from GitHub.',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// Normalize path separators to forward slashes for consistent matching.
|
// Normalize path separators to forward slashes for consistent matching.
|
||||||
const realPath = fs.realpathSync(cliPath).replace(/\\/g, '/');
|
const realPath = fs.realpathSync(cliPath).replace(/\\/g, '/');
|
||||||
const normalizedProjectRoot = projectRoot?.replace(/\\/g, '/');
|
const normalizedProjectRoot = projectRoot?.replace(/\\/g, '/');
|
||||||
|
|||||||
Reference in New Issue
Block a user