diff --git a/packages/cli/src/utils/handleAutoUpdate.test.ts b/packages/cli/src/utils/handleAutoUpdate.test.ts index 0d17afc520..b5c877532a 100644 --- a/packages/cli/src/utils/handleAutoUpdate.test.ts +++ b/packages/cli/src/utils/handleAutoUpdate.test.ts @@ -123,6 +123,24 @@ describe('handleAutoUpdate', () => { expect(mockSpawn).not.toHaveBeenCalled(); }); + it.each([ + PackageManager.NPX, + PackageManager.PNPX, + PackageManager.BUNX, + ])('should suppress update notifications when running via %s', (packageManager) => { + mockGetInstallationInfo.mockReturnValue({ + updateCommand: undefined, + updateMessage: `Running via ${packageManager}, update not applicable.`, + isGlobal: false, + packageManager, + }); + + handleAutoUpdate(mockUpdateInfo, mockSettings, '/root', mockSpawn); + + expect(mockUpdateEventEmitter.emit).not.toHaveBeenCalled(); + expect(mockSpawn).not.toHaveBeenCalled(); + }); + it('should emit "update-received" but not update if no update command is found', () => { mockGetInstallationInfo.mockReturnValue({ updateCommand: undefined, diff --git a/packages/cli/src/utils/handleAutoUpdate.ts b/packages/cli/src/utils/handleAutoUpdate.ts index a0691a0c6e..12b686b953 100644 --- a/packages/cli/src/utils/handleAutoUpdate.ts +++ b/packages/cli/src/utils/handleAutoUpdate.ts @@ -6,7 +6,7 @@ import type { UpdateObject } from '../ui/utils/updateCheck.js'; import type { LoadedSettings } from '../config/settings.js'; -import { getInstallationInfo } from './installationInfo.js'; +import { getInstallationInfo, PackageManager } from './installationInfo.js'; import { updateEventEmitter } from './updateEventEmitter.js'; import type { HistoryItem } from '../ui/types.js'; import { MessageType } from '../ui/types.js'; @@ -32,6 +32,16 @@ export function handleAutoUpdate( settings.merged.general?.disableAutoUpdate ?? false, ); + if ( + [ + PackageManager.NPX, + PackageManager.PNPX, + PackageManager.BUNX + ].includes(installationInfo.packageManager) + ) { + return; + } + let combinedMessage = info.message; if (installationInfo.updateMessage) { combinedMessage += `\n${installationInfo.updateMessage}`;