(ideType: IdeType)
| 936 | } |
| 937 | |
| 938 | async function installIDEExtension(ideType: IdeType): Promise<string | null> { |
| 939 | if (isVSCodeIde(ideType)) { |
| 940 | const command = await getVSCodeIDECommand(ideType) |
| 941 | |
| 942 | if (command) { |
| 943 | if (isInternalBuild()) { |
| 944 | return await installFromArtifactory(command) |
| 945 | } |
| 946 | let version = await getInstalledVSCodeExtensionVersion(command) |
| 947 | // If it's not installed or the version is older than the one we have bundled, |
| 948 | if (!version || lt(version, getClaudeCodeVersion())) { |
| 949 | // `code` may crash when invoked too quickly in succession |
| 950 | await sleep(500) |
| 951 | const result = await execFileNoThrowWithCwd( |
| 952 | command, |
| 953 | ['--force', '--install-extension', 'anthropic.claude-code'], |
| 954 | { |
| 955 | env: getInstallationEnv(), |
| 956 | }, |
| 957 | ) |
| 958 | if (result.code !== 0) { |
| 959 | throw new Error(`${result.code}: ${result.error} ${result.stderr}`) |
| 960 | } |
| 961 | version = getClaudeCodeVersion() |
| 962 | } |
| 963 | return version |
| 964 | } |
| 965 | } |
| 966 | // No automatic installation for JetBrains IDEs as it is not supported in native |
| 967 | // builds. We show a prominent notice for them to download from the marketplace |
| 968 | // instead. |
| 969 | return null |
| 970 | } |
| 971 | |
| 972 | function getInstallationEnv(): NodeJS.ProcessEnv | undefined { |
| 973 | // Cursor on Linux may incorrectly implement |
no test coverage detected