function readTemplate
readTemplate(relativePath: string): Promise<string>

Reads a template file by relative path. Two runtimes to satisfy:

  • Node SEA binary: assets live in the SEA store (node:sea).
  • Node / Deno (source, npm, or deno compile binary): plain fs.readFile — Deno's node:fs compat reads --included files from the compiled VFS too (verified on Deno 2.9.2; earlier versions rejected it, needing Deno.readFile).

The two __dirname-relative bases cover (a) running from source where templates are 2 levels above lib/utils/, and (b) running from the bundled dist/ where __dirname is the package root so templates are only 1 level up.

// Defined, not invoked: reads template files from the package directory (or the SEA store).
async function loadRunnerHtml(): Promise<string> {
  return await readTemplate('test-runner.html'); // throws when the asset is missing entirely
}

Parameters

relativePath: string

Return Type

Promise<string>

Usage

import { readTemplate } from "lib/utils/read-template.ts";