MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / installUpdate

Function installUpdate

apps/kimi-code/src/cli/update/preflight.ts:484–509  ·  view source on GitHub ↗
(
  source: InstallSource,
  version: string,
  platform: NodeJS.Platform,
)

Source from the content-addressed store, hash-verified

482}
483
484export async function installUpdate(
485 source: InstallSource,
486 version: string,
487 platform: NodeJS.Platform,
488): Promise<void> {
489 const { cmd, args } = spawnForSource(source, version, platform);
490 await new Promise<void>((resolve, reject) => {
491 // Windows package managers (npm/pnpm/yarn) are .cmd shims. Since the
492 // CVE-2024-27980 fix, Node throws EINVAL when spawning a .cmd/.bat without
493 // a shell, so run through the shell on win32. The version is a validated
494 // semver and the package name is a constant, so args are shell-safe.
495 const child = spawn(cmd, [...args], {
496 stdio: 'inherit',
497 shell: platform === 'win32' ? true : undefined,
498 });
499 child.once('error', reject);
500 child.once('exit', (code, signal) => {
501 if (code === 0) {
502 resolve();
503 return;
504 }
505 const detail = signal !== null ? `signal ${signal}` : `code ${String(code)}`;
506 reject(new Error(`${cmd} exited with ${detail}`));
507 });
508 });
509}
510
511async function startBackgroundInstall(
512 state: UpdateInstallState,

Callers 1

runUpdatePreflightFunction · 0.85

Calls 5

spawnForSourceFunction · 0.85
rejectFunction · 0.85
onceMethod · 0.65
spawnFunction · 0.50
resolveFunction · 0.50

Tested by

no test coverage detected