mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 16:57:46 +00:00
feat(autoupdate): Improve update check and refactor for testability (#5389)
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user