| 8 | |
| 9 | // Helper function to properly convert file paths to URLs, especially for Windows |
| 10 | function createFileURL(filePath: string): URL { |
| 11 | if (isWindows) { |
| 12 | // Ensure path uses forward slashes for URL format |
| 13 | const normalizedPath = filePath.replace(/\\/g, '/'); |
| 14 | // Ensure path has proper file:// prefix |
| 15 | if (normalizedPath.startsWith('/')) { |
| 16 | return new URL(`file://${normalizedPath}`); |
| 17 | } else { |
| 18 | return new URL(`file:///${normalizedPath}`); |
| 19 | } |
| 20 | } else { |
| 21 | // For non-Windows, we can use the built-in function |
| 22 | return pathToFileURL(filePath); |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | export async function runUninstall() { |
| 27 | try { |