Skip to content

Commit e6be420

Browse files
baixiangerclaude
andcommitted
Fix two Windows bugs: Chrome path and token save
1. Chrome path: use path.join() instead of template string backslashes which get mangled by Bun's string interpolation on Windows 2. Token save: replace Bun.write with writeFileSync — Bun.write is async and may not flush before process.exit() on Windows Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7029836 commit e6be420

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,13 @@ async function ensureChrome(cdpUrl: string): Promise<void> {
8888
if (userPath) {
8989
bin = userPath;
9090
} else {
91+
const chromeSub = join("Google", "Chrome", "Application", "chrome.exe");
9192
const defaults: Record<string, string[]> = {
9293
darwin: ["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"],
9394
win32: [
94-
`${process.env.PROGRAMFILES}\\Google\\Chrome\\Application\\chrome.exe`,
95-
`${process.env["PROGRAMFILES(X86)"]}\\Google\\Chrome\\Application\\chrome.exe`,
96-
`${process.env.LOCALAPPDATA}\\Google\\Chrome\\Application\\chrome.exe`,
95+
...(process.env.PROGRAMFILES ? [join(process.env.PROGRAMFILES, chromeSub)] : []),
96+
...(process.env["PROGRAMFILES(X86)"] ? [join(process.env["PROGRAMFILES(X86)"], chromeSub)] : []),
97+
...(process.env.LOCALAPPDATA ? [join(process.env.LOCALAPPDATA, chromeSub)] : []),
9798
],
9899
linux: ["google-chrome", "google-chrome-stable", "chromium-browser"],
99100
};

lib/auth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* 2. Manual: user pastes token from browser devtools
88
*/
99

10-
import { existsSync, mkdirSync } from "fs";
10+
import { existsSync, mkdirSync, writeFileSync } from "fs";
1111
import { homedir } from "os";
1212
import { join } from "path";
1313

@@ -25,7 +25,7 @@ export interface TokenData {
2525

2626
/** Save token to disk */
2727
export function saveToken(data: TokenData): void {
28-
Bun.write(TOKEN_PATH, JSON.stringify(data, null, 2));
28+
writeFileSync(TOKEN_PATH, JSON.stringify(data, null, 2));
2929
}
3030

3131
/** Load saved token */

0 commit comments

Comments
 (0)