* Internal implementation of IDE detection.
()
| 1132 | * Internal implementation of IDE detection. |
| 1133 | */ |
| 1134 | async function detectRunningIDEsImpl(): Promise<IdeType[]> { |
| 1135 | const runningIDEs: IdeType[] = [] |
| 1136 | |
| 1137 | try { |
| 1138 | const platform = getPlatform() |
| 1139 | if (platform === 'macos') { |
| 1140 | // On macOS, use ps with process name matching |
| 1141 | const result = await execa( |
| 1142 | 'ps aux | grep -E "Visual Studio Code|Code Helper|Cursor Helper|Windsurf Helper|IntelliJ IDEA|PyCharm|WebStorm|PhpStorm|RubyMine|CLion|GoLand|Rider|DataGrip|AppCode|DataSpell|Aqua|Gateway|Fleet|Android Studio" | grep -v grep', |
| 1143 | { shell: true, reject: false }, |
| 1144 | ) |
| 1145 | const stdout = result.stdout ?? '' |
| 1146 | for (const [ide, config] of Object.entries(supportedIdeConfigs)) { |
| 1147 | for (const keyword of config.processKeywordsMac) { |
| 1148 | if (stdout.includes(keyword)) { |
| 1149 | runningIDEs.push(ide as IdeType) |
| 1150 | break |
| 1151 | } |
| 1152 | } |
| 1153 | } |
| 1154 | } else if (platform === 'windows') { |
| 1155 | // On Windows, use tasklist with findstr for multiple patterns |
| 1156 | const result = await execa( |
| 1157 | 'tasklist | findstr /I "Code.exe Cursor.exe Windsurf.exe idea64.exe pycharm64.exe webstorm64.exe phpstorm64.exe rubymine64.exe clion64.exe goland64.exe rider64.exe datagrip64.exe appcode.exe dataspell64.exe aqua64.exe gateway64.exe fleet.exe studio64.exe"', |
| 1158 | { shell: true, reject: false }, |
| 1159 | ) |
| 1160 | const stdout = result.stdout ?? '' |
| 1161 | |
| 1162 | const normalizedStdout = stdout.toLowerCase() |
| 1163 | |
| 1164 | for (const [ide, config] of Object.entries(supportedIdeConfigs)) { |
| 1165 | for (const keyword of config.processKeywordsWindows) { |
| 1166 | if (normalizedStdout.includes(keyword.toLowerCase())) { |
| 1167 | runningIDEs.push(ide as IdeType) |
| 1168 | break |
| 1169 | } |
| 1170 | } |
| 1171 | } |
| 1172 | } else if (platform === 'linux') { |
| 1173 | // On Linux, use ps with process name matching |
| 1174 | const result = await execa( |
| 1175 | 'ps aux | grep -E "code|cursor|windsurf|idea|pycharm|webstorm|phpstorm|rubymine|clion|goland|rider|datagrip|dataspell|aqua|gateway|fleet|android-studio" | grep -v grep', |
| 1176 | { shell: true, reject: false }, |
| 1177 | ) |
| 1178 | const stdout = result.stdout ?? '' |
| 1179 | |
| 1180 | const normalizedStdout = stdout.toLowerCase() |
| 1181 | |
| 1182 | for (const [ide, config] of Object.entries(supportedIdeConfigs)) { |
| 1183 | for (const keyword of config.processKeywordsLinux) { |
| 1184 | if (normalizedStdout.includes(keyword)) { |
| 1185 | if (ide !== 'vscode') { |
| 1186 | runningIDEs.push(ide as IdeType) |
| 1187 | break |
| 1188 | } else if ( |
| 1189 | !normalizedStdout.includes('cursor') && |
| 1190 | !normalizedStdout.includes('appcode') |
| 1191 | ) { |
no test coverage detected