MCPcopy
hub / github.com/codeaashu/claude-code / installIDEExtension

Function installIDEExtension

src/utils/ide.ts:879–911  ·  view source on GitHub ↗
(ideType: IdeType)

Source from the content-addressed store, hash-verified

877}
878
879async function installIDEExtension(ideType: IdeType): Promise<string | null> {
880 if (isVSCodeIde(ideType)) {
881 const command = await getVSCodeIDECommand(ideType)
882
883 if (command) {
884 if (process.env.USER_TYPE === 'ant') {
885 return await installFromArtifactory(command)
886 }
887 let version = await getInstalledVSCodeExtensionVersion(command)
888 // If it's not installed or the version is older than the one we have bundled,
889 if (!version || lt(version, getClaudeCodeVersion())) {
890 // `code` may crash when invoked too quickly in succession
891 await sleep(500)
892 const result = await execFileNoThrowWithCwd(
893 command,
894 ['--force', '--install-extension', 'anthropic.claude-code'],
895 {
896 env: getInstallationEnv(),
897 },
898 )
899 if (result.code !== 0) {
900 throw new Error(`${result.code}: ${result.error} ${result.stderr}`)
901 }
902 version = getClaudeCodeVersion()
903 }
904 return version
905 }
906 }
907 // No automatic installation for JetBrains IDEs as it is not supported in native
908 // builds. We show a prominent notice for them to download from the marketplace
909 // instead.
910 return null
911}
912
913function getInstallationEnv(): NodeJS.ProcessEnv | undefined {
914 // Cursor on Linux may incorrectly implement

Callers 1

maybeInstallIDEExtensionFunction · 0.85

Calls 9

isVSCodeIdeFunction · 0.85
getVSCodeIDECommandFunction · 0.85
installFromArtifactoryFunction · 0.85
ltFunction · 0.85
getClaudeCodeVersionFunction · 0.85
execFileNoThrowWithCwdFunction · 0.85
getInstallationEnvFunction · 0.85
sleepFunction · 0.70

Tested by

no test coverage detected