UNPKG

prettylint

Version:
14 lines (13 loc) 406 B
// modified from https://github.com/prettier/prettier/blob/3.0.0/src/utils/read-file.js import fs from "node:fs/promises"; export async function readFile(filename) { try { return await fs.readFile(filename, "utf8"); } catch (error) { if (error.code === "ENOENT") { return; } throw new Error(`Unable to read '${filename}': ${error.message}`); } }