MCPcopy Index your code
hub / github.com/codeaashu/claude-code / detectJetBrainsIDEFromParentProcessAsync

Function detectJetBrainsIDEFromParentProcessAsync

src/utils/envDynamic.ts:64–96  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

62let jetBrainsIDECache: string | null | undefined
63
64async 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
98export async function getTerminalWithJetBrainsDetectionAsync(): Promise<
99 string | null

Callers 2

initJetBrainsDetectionFunction · 0.85

Calls 1

getAncestorCommandsAsyncFunction · 0.85

Tested by

no test coverage detected