Path: blob/main/src/command/check/check-render.ts
6450 views
/*1* check-render.ts2*3* Copyright (C) 2020-2022 Posit Software, PBC4*/56import { render } from "../render/render-shared.ts";7import type { RenderServiceWithLifetime } from "../render/types.ts";89/**10* Options for test-rendering a document during check operations11*/12export interface CheckRenderOptions {13/** Markdown content to render */14content: string;15/** Language identifier (e.g., "python", "r", "julia") */16language: string;17/** Render services for temp file management and rendering */18services: RenderServiceWithLifetime;19}2021/**22* Result of a check render operation23*/24export interface CheckRenderResult {25/** Whether the render succeeded */26success: boolean;27/** Error if render failed */28error?: Error;29}3031/**32* Test-render a document for validation during check operations33*34* Creates a temporary file with the provided content, renders it with35* appropriate engine settings, and returns success/failure status.36* Used by checkInstallation implementations to verify engines work.37*/38export async function checkRender(39options: CheckRenderOptions,40): Promise<CheckRenderResult> {41const { content, services } = options;4243// Create temporary file44const tempFile = services.temp.createFile({ suffix: ".qmd" });4546// Write content to file47Deno.writeTextFileSync(tempFile, content);4849// Render with appropriate flags50const result = await render(tempFile, {51services,52flags: { quiet: true, executeDaemon: 0 },53});5455// Return simplified result56return {57success: !result.error,58error: result.error,59};60}616263