(ideType: IdeType)
| 877 | } |
| 878 | |
| 879 | async 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 | |
| 913 | function getInstallationEnv(): NodeJS.ProcessEnv | undefined { |
| 914 | // Cursor on Linux may incorrectly implement |
no test coverage detected