This repository has been archived on 2023-05-27. You can view files and clone it, but cannot push or open issues or pull requests.
fediverse-imagebot/src/helpers/config.ts

21 lines
554 B
TypeScript

import args from "./cli";
import crashHandler from "./errors";
import { readFile } from "fs/promises";
// Read the config file and return the contents as a JSON object
export default async function config() {
try {
return JSON.parse(
await readFile(args.config, "utf8")
.catch(err => {
crashHandler("Error reading config file.", err);
return ("");
})
);
}
catch (e: unknown) {
crashHandler("Error reading config file.", e);
}
}