|
1 | 1 | import { execFile } from "child_process"; |
2 | | -import { existsSync } from "fs"; |
| 2 | +import { existsSync, readdirSync } from "fs"; |
3 | 3 | import { homedir } from "os"; |
4 | 4 | import { join } from "path"; |
5 | 5 | import { promisify } from "util"; |
@@ -48,9 +48,29 @@ class WindowsPlatform implements PlatformAdapter { |
48 | 48 | } |
49 | 49 |
|
50 | 50 | async isWisprFlowInstalled(): Promise<boolean> { |
51 | | - const localAppData = process.env.LOCALAPPDATA; |
52 | | - if (!localAppData) return false; |
53 | | - return existsSync(join(localAppData, "WisprFlow", "Wispr Flow.exe")); |
| 51 | + const searchDirs = [ |
| 52 | + process.env.LOCALAPPDATA ?? join(homedir(), "AppData", "Local"), |
| 53 | + process.env.PROGRAMFILES ?? "C:\\Program Files", |
| 54 | + process.env["PROGRAMFILES(X86)"] ?? "C:\\Program Files (x86)", |
| 55 | + ]; |
| 56 | + for (const base of searchDirs) { |
| 57 | + const wisprDir = join(base, "WisprFlow"); |
| 58 | + if (!existsSync(wisprDir)) continue; |
| 59 | + if (existsSync(join(wisprDir, "Wispr Flow.exe"))) return true; |
| 60 | + try { |
| 61 | + if ( |
| 62 | + readdirSync(wisprDir).some( |
| 63 | + (e) => |
| 64 | + e.startsWith("app-") && |
| 65 | + existsSync(join(wisprDir, e, "Wispr Flow.exe")), |
| 66 | + ) |
| 67 | + ) |
| 68 | + return true; |
| 69 | + } catch { |
| 70 | + /* continue */ |
| 71 | + } |
| 72 | + } |
| 73 | + return false; |
54 | 74 | } |
55 | 75 |
|
56 | 76 | async openWisprFlow(url: string): Promise<void> { |
|
0 commit comments