* Internal implementation of IDE detection.
()
| 1073 | * Internal implementation of IDE detection. |
| 1074 | */ |
| 1075 | async function detectRunningIDEsImpl(): Promise<IdeType[]> { |
| 1076 | const runningIDEs: IdeType[] = [] |
| 1077 | |
| 1078 | try { |
| 1079 | const platform = getPlatform() |
| 1080 | if (platform === 'macos') { |
| 1081 | // On macOS, use ps with process name matching |
| 1082 | const result = await execa( |
| 1083 | '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', |
| 1084 | { shell: true, reject: false }, |
| 1085 | ) |
| 1086 | const stdout = result.stdout ?? '' |
| 1087 | for (const [ide, config] of Object.entries(supportedIdeConfigs)) { |
| 1088 | for (const keyword of config.processKeywordsMac) { |
| 1089 | if (stdout.includes(keyword)) { |
| 1090 | runningIDEs.push(ide as IdeType) |
| 1091 | break |
| 1092 | } |
| 1093 | } |
| 1094 | } |
| 1095 | } else if (platform === 'windows') { |
| 1096 | // On Windows, use tasklist with findstr for multiple patterns |
| 1097 | const result = await execa( |
| 1098 | '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"', |
| 1099 | { shell: true, reject: false }, |
| 1100 | ) |
| 1101 | const stdout = result.stdout ?? '' |
| 1102 | |
| 1103 | const normalizedStdout = stdout.toLowerCase() |
| 1104 | |
| 1105 | for (const [ide, config] of Object.entries(supportedIdeConfigs)) { |
| 1106 | for (const keyword of config.processKeywordsWindows) { |
| 1107 | if (normalizedStdout.includes(keyword.toLowerCase())) { |
| 1108 | runningIDEs.push(ide as IdeType) |
| 1109 | break |
| 1110 | } |
| 1111 | } |
| 1112 | } |
| 1113 | } else if (platform === 'linux') { |
| 1114 | // On Linux, use ps with process name matching |
| 1115 | const result = await execa( |
| 1116 | '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', |
| 1117 | { shell: true, reject: false }, |
| 1118 | ) |
| 1119 | const stdout = result.stdout ?? '' |
| 1120 | |
| 1121 | const normalizedStdout = stdout.toLowerCase() |
| 1122 | |
| 1123 | for (const [ide, config] of Object.entries(supportedIdeConfigs)) { |
| 1124 | for (const keyword of config.processKeywordsLinux) { |
| 1125 | if (normalizedStdout.includes(keyword)) { |
| 1126 | if (ide !== 'vscode') { |
| 1127 | runningIDEs.push(ide as IdeType) |
| 1128 | break |
| 1129 | } else if ( |
| 1130 | !normalizedStdout.includes('cursor') && |
| 1131 | !normalizedStdout.includes('appcode') |
| 1132 | ) { |
no test coverage detected