MCPcopy Create free account
hub / github.com/claude-code-best/claude-code / installLatestImpl

Function installLatestImpl

src/utils/nativeInstaller/installer.ts:973–1013  ·  view source on GitHub ↗
(
  channelOrVersion: string,
  forceReinstall: boolean = false,
)

Source from the content-addressed store, hash-verified

971}
972
973async function installLatestImpl(
974 channelOrVersion: string,
975 forceReinstall: boolean = false,
976): Promise<InstallLatestResult> {
977 const updateResult = await updateLatest(channelOrVersion, forceReinstall)
978
979 if (!updateResult.success) {
980 return {
981 latestVersion: null,
982 wasUpdated: false,
983 lockFailed: updateResult.lockFailed,
984 lockHolderPid: updateResult.lockHolderPid,
985 }
986 }
987
988 // Installation succeeded (early return above covers failure). Mark as native
989 // and disable legacy auto-updater to protect symlinks.
990 const config = getGlobalConfig()
991 if (config.installMethod !== 'native') {
992 saveGlobalConfig(current => ({
993 ...current,
994 installMethod: 'native',
995 // Disable legacy auto-updater to prevent npm sessions from deleting native symlinks.
996 // Native installations use NativeAutoUpdater instead, which respects native installation.
997 autoUpdates: false,
998 // Mark this as protection-based, not user preference
999 autoUpdatesProtectedForNative: true,
1000 }))
1001 logForDebugging(
1002 'Native installer: Set installMethod to "native" and disabled legacy auto-updater for protection',
1003 )
1004 }
1005
1006 void cleanupOldVersions()
1007
1008 return {
1009 latestVersion: updateResult.latestVersion,
1010 wasUpdated: updateResult.success,
1011 lockFailed: false,
1012 }
1013}
1014
1015async function getVersionFromSymlink(
1016 symlinkPath: string,

Callers 1

installLatestFunction · 0.85

Calls 5

updateLatestFunction · 0.85
getGlobalConfigFunction · 0.85
saveGlobalConfigFunction · 0.85
cleanupOldVersionsFunction · 0.85
logForDebuggingFunction · 0.50

Tested by

no test coverage detected