UNPKG

zephyr-rspress-plugin

Version:

Rspress plugin for Zephyr

27 lines (26 loc) • 912 B
import "node:module"; import promises from "node:fs/promises"; import node_path from "node:path"; import { ZeErrors, ZephyrError } from "zephyr-agent"; async function buildAssetMapFromFiles(root, files) { const resolvedRoot = node_path.resolve(root); const assetEntries = await Promise.all(files.map(async (rel)=>{ const abs = node_path.resolve(root, rel); if (!abs.startsWith(resolvedRoot)) throw new ZephyrError(ZeErrors.ERR_UNKNOWN, { message: `Invalid file path: ${rel}` }); const content = await promises.readFile(abs); const source = { source: ()=>content, size: ()=>content.length, buffer: ()=>content }; return [ rel, source ]; })); return Object.fromEntries(assetEntries); } export { buildAssetMapFromFiles }; //# sourceMappingURL=buildAssets.mjs.map