10 lines
242 B
TypeScript
Raw Normal View History

2024-08-16 01:23:55 +07:00
import fs from "node:fs";
import toml from "toml";
export const readTomlFile = <T = any>(path?: string | null) => {
if (!path || !fs.existsSync(path)) {
return undefined;
}
return toml.parse(fs.readFileSync(path, "utf8")) as T;
};