MCPcopy Index your code
hub / github.com/codeaashu/claude-code / update

Function update

src/cli/update.ts:30–422  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

28import { getInitialSettings } from 'src/utils/settings/settings.js'
29
30export async function update() {
31 logEvent('tengu_update_check', {})
32 writeToStdout(`Current version: ${MACRO.VERSION}\n`)
33
34 const channel = getInitialSettings()?.autoUpdatesChannel ?? 'latest'
35 writeToStdout(`Checking for updates to ${channel} version...\n`)
36
37 logForDebugging('update: Starting update check')
38
39 // Run diagnostic to detect potential issues
40 logForDebugging('update: Running diagnostic')
41 const diagnostic = await getDoctorDiagnostic()
42 logForDebugging(`update: Installation type: ${diagnostic.installationType}`)
43 logForDebugging(
44 `update: Config install method: ${diagnostic.configInstallMethod}`,
45 )
46
47 // Check for multiple installations
48 if (diagnostic.multipleInstallations.length > 1) {
49 writeToStdout('\n')
50 writeToStdout(chalk.yellow('Warning: Multiple installations found') + '\n')
51 for (const install of diagnostic.multipleInstallations) {
52 const current =
53 diagnostic.installationType === install.type
54 ? ' (currently running)'
55 : ''
56 writeToStdout(`- ${install.type} at ${install.path}${current}\n`)
57 }
58 }
59
60 // Display warnings if any exist
61 if (diagnostic.warnings.length > 0) {
62 writeToStdout('\n')
63 for (const warning of diagnostic.warnings) {
64 logForDebugging(`update: Warning detected: ${warning.issue}`)
65
66 // Don't skip PATH warnings - they're always relevant
67 // The user needs to know that 'which claude' points elsewhere
68 logForDebugging(`update: Showing warning: ${warning.issue}`)
69
70 writeToStdout(chalk.yellow(`Warning: ${warning.issue}\n`))
71
72 writeToStdout(chalk.bold(`Fix: ${warning.fix}\n`))
73 }
74 }
75
76 // Update config if installMethod is not set (but skip for package managers)
77 const config = getGlobalConfig()
78 if (
79 !config.installMethod &&
80 diagnostic.installationType !== 'package-manager'
81 ) {
82 writeToStdout('\n')
83 writeToStdout('Updating configuration to track installation method...\n')
84 let detectedMethod: 'local' | 'native' | 'global' | 'unknown' = 'unknown'
85
86 // Map diagnostic installation type to config install method
87 switch (diagnostic.installationType) {

Callers 1

runFunction · 0.50

Calls 15

logEventFunction · 0.85
writeToStdoutFunction · 0.85
getInitialSettingsFunction · 0.85
logForDebuggingFunction · 0.85
getDoctorDiagnosticFunction · 0.85
getGlobalConfigFunction · 0.85
saveGlobalConfigFunction · 0.85
gracefulShutdownFunction · 0.85
gteFunction · 0.85
removeInstalledSymlinkFunction · 0.85
localInstallationExistsFunction · 0.85

Tested by

no test coverage detected