Skip to content

Commit 896bef2

Browse files
authored
Merge pull request #1015 from quarto-dev/msedge-chromium
Add support for using Microsoft Edge instead of Chrome on Windows
2 parents cef21d5 + 98ec12f commit 896bef2

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

src/core/puppeteer.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { readRegistryKey } from "./windows.ts";
99
import { which } from "./path.ts";
1010
import { error, info } from "log/mod.ts";
1111
import { fetcher } from "../command/tools/tools/chromium.ts";
12+
import { existsSync } from "https://deno.land/[email protected]/fs/mod.ts";
1213

1314
// deno-lint-ignore no-explicit-any
1415
let puppeteerImport: any = undefined;
@@ -209,17 +210,28 @@ async function findChrome(): Promise<string | undefined> {
209210
}
210211
} else if (Deno.build.os === "windows") {
211212
// Try the HKLM key
212-
path = await readRegistryKey(
213-
"HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\chrome.exe",
214-
"(Default)",
215-
);
216-
217-
// Try the HKCR key
218-
if (!path) {
213+
const programs = ["chrome.exe", "msedge.exe"];
214+
for (let i = 0; i < programs.length; i++) {
219215
path = await readRegistryKey(
220-
"HKCR\\ChromeHTML\\shell\\open\\command",
216+
"HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\" +
217+
programs[i],
221218
"(Default)",
222219
);
220+
if (path && existsSync(path)) break;
221+
}
222+
223+
// Try the HKCR key
224+
if (!path) {
225+
const regKeys = ["ChromeHTML", "MSEdgeHTM"];
226+
for (let i = 0; i < regKeys.length; i++) {
227+
path = await readRegistryKey(
228+
`HKCR\\${regKeys[i]}\\shell\\open\\command`,
229+
"(Default)",
230+
);
231+
path = path?.match(/"(.*)"/);
232+
path = path ? path[1] : undefined;
233+
if (path && existsSync(path)) break;
234+
}
223235
}
224236
}
225237
return path;

0 commit comments

Comments
 (0)