| 256 | } |
| 257 | |
| 258 | private async installToEditor( |
| 259 | vsixPath: string, |
| 260 | autoClose: boolean, |
| 261 | timeout: number, |
| 262 | editor: "code" | "cursor", |
| 263 | ): Promise<void> { |
| 264 | try { |
| 265 | const command = editor === "cursor" ? "cursor" : "code"; |
| 266 | |
| 267 | // Install the extension |
| 268 | execSync(`${command} --install-extension "${vsixPath}"`, { |
| 269 | stdio: "pipe", |
| 270 | }); |
| 271 | |
| 272 | console.log("✅ Theme installed successfully!"); |
| 273 | |
| 274 | if (autoClose) { |
| 275 | // Small delay to ensure installation completes |
| 276 | await new Promise((resolve) => setTimeout(resolve, timeout)); |
| 277 | |
| 278 | try { |
| 279 | // Close all editor windows |
| 280 | if (process.platform === "darwin") { |
| 281 | const appName = |
| 282 | editor === "cursor" ? "Cursor" : "Visual Studio Code"; |
| 283 | execSync(`osascript -e "quit app \\"${appName}\\""`); |
| 284 | } else if (process.platform === "win32") { |
| 285 | const processName = editor === "cursor" ? "Cursor.exe" : "Code.exe"; |
| 286 | execSync(`taskkill /F /IM ${processName}`); |
| 287 | } else { |
| 288 | execSync(`pkill -f "${command}"`); |
| 289 | } |
| 290 | } catch (_error) { |
| 291 | // Silently fail on auto-close |
| 292 | } |
| 293 | } |
| 294 | } catch (error) { |
| 295 | throw new Error(`Failed to install theme: ${error}`); |
| 296 | } |
| 297 | } |
| 298 | } |