diff options
| author | Gal Zahavi <[email protected]> | 2025-08-01 20:17:32 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-02 03:17:32 +0000 |
| commit | 820169ba2e0777ee2bee240f063649cc4b2b107f (patch) | |
| tree | 1c8e6105512f0fc417442fb6ba27637b744ee739 /packages/cli/src/utils/handleAutoUpdate.ts | |
| parent | 15a1f1af9d0e4628e9e82f81d384d614899770e3 (diff) | |
feat(autoupdate): Improve update check and refactor for testability (#5389)
Diffstat (limited to 'packages/cli/src/utils/handleAutoUpdate.ts')
| -rw-r--r-- | packages/cli/src/utils/handleAutoUpdate.ts | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/packages/cli/src/utils/handleAutoUpdate.ts b/packages/cli/src/utils/handleAutoUpdate.ts index 1ef2d475..03a6a8d6 100644 --- a/packages/cli/src/utils/handleAutoUpdate.ts +++ b/packages/cli/src/utils/handleAutoUpdate.ts @@ -4,17 +4,19 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { spawn } from 'node:child_process'; import { UpdateObject } from '../ui/utils/updateCheck.js'; import { LoadedSettings } from '../config/settings.js'; import { getInstallationInfo } from './installationInfo.js'; import { updateEventEmitter } from './updateEventEmitter.js'; import { HistoryItem, MessageType } from '../ui/types.js'; +import { spawnWrapper } from './spawnWrapper.js'; +import { spawn } from 'child_process'; export function handleAutoUpdate( info: UpdateObject | null, settings: LoadedSettings, projectRoot: string, + spawnFn: typeof spawn = spawnWrapper, ) { if (!info) { return; @@ -37,13 +39,13 @@ export function handleAutoUpdate( if (!installationInfo.updateCommand || settings.merged.disableAutoUpdate) { return; } + const isNightly = info.update.latest.includes('nightly'); const updateCommand = installationInfo.updateCommand.replace( '@latest', - `@${info.update.latest}`, + isNightly ? '@nightly' : `@${info.update.latest}`, ); - - const updateProcess = spawn(updateCommand, { stdio: 'pipe', shell: true }); + const updateProcess = spawnFn(updateCommand, { stdio: 'pipe', shell: true }); let errorOutput = ''; updateProcess.stderr.on('data', (data) => { errorOutput += data.toString(); |
