()
| 62 | let jetBrainsIDECache: string | null | undefined |
| 63 | |
| 64 | async function detectJetBrainsIDEFromParentProcessAsync(): Promise< |
| 65 | string | null |
| 66 | > { |
| 67 | if (jetBrainsIDECache !== undefined) { |
| 68 | return jetBrainsIDECache |
| 69 | } |
| 70 | |
| 71 | if (process.platform === 'darwin') { |
| 72 | jetBrainsIDECache = null |
| 73 | return null // macOS uses bundle ID detection which is already handled |
| 74 | } |
| 75 | |
| 76 | try { |
| 77 | // Get ancestor commands in a single call (avoids sync bash in loop) |
| 78 | const commands = await getAncestorCommandsAsync(process.pid, 10) |
| 79 | |
| 80 | for (const command of commands) { |
| 81 | const lowerCommand = command.toLowerCase() |
| 82 | // Check for specific JetBrains IDEs in the command line |
| 83 | for (const ide of JETBRAINS_IDES) { |
| 84 | if (lowerCommand.includes(ide)) { |
| 85 | jetBrainsIDECache = ide |
| 86 | return ide |
| 87 | } |
| 88 | } |
| 89 | } |
| 90 | } catch { |
| 91 | // Silently fail - this is a best-effort detection |
| 92 | } |
| 93 | |
| 94 | jetBrainsIDECache = null |
| 95 | return null |
| 96 | } |
| 97 | |
| 98 | export async function getTerminalWithJetBrainsDetectionAsync(): Promise< |
| 99 | string | null |
no test coverage detected