import assert from "assert"; import { readFile } from "fs/promises"; import { readFileSync } from "fs"; /** * Fetch an environment variable */ export function env(variable: string, throwIfNotFound = true) { let value = process.env[variable]; if (throwIfNotFound) { assert(value !== undefined); } return value; } /** * Fetch a secret from a file */ export async function secret(path: string) { return (await readFile(path)).toString().trim(); } export function secretSync(path: string) { return readFileSync(path).toString().trim(); }