Skip to content

Commit 11c6705

Browse files
committed
Add some chrome information to quarto check
1 parent c504fc8 commit 11c6705

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

src/command/check/check.ts

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import { typstBinaryPath } from "../../core/typst.ts";
4848
import { quartoCacheDir } from "../../core/appdirs.ts";
4949
import { isWindows } from "../../deno_ral/platform.ts";
5050
import { makeStringEnumTypeEnforcer } from "../../typing/dynamic.ts";
51+
import { findChrome } from "../../core/puppeteer.ts";
5152

5253
export const kTargets = [
5354
"install",
@@ -212,11 +213,12 @@ async function checkInstall(services: RenderServices) {
212213
info("");
213214
const toolsMessage = "Checking tools....................";
214215
const toolsOutput: string[] = [];
216+
let tools: Awaited<ReturnType<typeof allTools>>;
215217
await withSpinner({
216218
message: toolsMessage,
217219
doneMessage: toolsMessage + "OK",
218220
}, async () => {
219-
const tools = await allTools();
221+
tools = await allTools();
220222

221223
for (const tool of tools.installed) {
222224
const version = await tool.installedVersion() || "(external install)";
@@ -260,6 +262,38 @@ async function checkInstall(services: RenderServices) {
260262
latexOutput.forEach((out) => info(out));
261263
info("");
262264

265+
const chromeHeadlessMessage = "Checking Chrome Headless....................";
266+
const chromeHeadlessOutput: string[] = [];
267+
await withSpinner({
268+
message: chromeHeadlessMessage,
269+
doneMessage: chromeHeadlessMessage + "OK",
270+
}, async () => {
271+
const chromeSystemPath = await findChrome();
272+
const chromiumQuartoPath = tools.installed.find((tool) =>
273+
tool.name === "chromium"
274+
);
275+
if (chromeSystemPath !== undefined) {
276+
chromeHeadlessOutput.push(`${kIndent}Using: Chrome found on system`);
277+
chromeHeadlessOutput.push(`${kIndent}Path: ${dirname(chromeSystemPath)}`);
278+
} else if (chromiumQuartoPath) {
279+
chromeHeadlessOutput.push(
280+
`${kIndent}Using: Chromium installed by Quarto`,
281+
);
282+
if (chromiumQuartoPath?.binDir) {
283+
chromeHeadlessOutput.push(
284+
`${kIndent}Path: ${chromiumQuartoPath?.binDir}`,
285+
);
286+
}
287+
chromeHeadlessOutput.push(
288+
`${kIndent}Version: ${chromiumQuartoPath.installedVersion}`,
289+
);
290+
} else {
291+
chromeHeadlessOutput.push(`${kIndent}Chrome: (not detected)`);
292+
}
293+
});
294+
chromeHeadlessOutput.forEach((out) => info(out));
295+
info("");
296+
263297
const kMessage = "Checking basic markdown render....";
264298
await withSpinner({
265299
message: kMessage,

src/core/puppeteer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ export async function withHeadlessBrowser<T>(
200200
}
201201
}
202202

203-
async function findChrome(): Promise<string | undefined> {
203+
export async function findChrome(): Promise<string | undefined> {
204204
let path;
205205
// First check env var and use this path if specified
206206
const envPath = Deno.env.get("QUARTO_CHROMIUM");

0 commit comments

Comments
 (0)