UNPKG

file-cms

Version:

File based Content Management System, easy to use with content stored in native file system

15 lines (14 loc) 435 B
import { join } from "path"; import { Config } from "./Config"; import { readFile } from "fs/promises"; import { FileNotFoundError } from "./errors/FileNotFoundError"; export var getFile = function (path, options) { var rootDir = Config.getRootDir(); var filePath = join(rootDir, path); try { return readFile(filePath, options); } catch (e) { throw new FileNotFoundError(rootDir, path, e); } };