15 lines
277 B
TypeScript
Raw Normal View History

2024-08-16 01:23:55 +07:00
import toml from "toml";
2024-08-17 04:55:01 +07:00
export const readTomlFile = async <T = any>(path?: string | null) => {
if (!path) {
2024-08-16 01:23:55 +07:00
return undefined;
}
2024-08-17 04:55:01 +07:00
const file = Bun.file(path);
if (!(await file.exists())) {
return undefined;
}
return toml.parse(await file.text()) as T;
2024-08-16 01:23:55 +07:00
};