diff --git a/src/getLocalImage.ts b/src/getLocalImage.ts index 24d950b..9d9f040 100644 --- a/src/getLocalImage.ts +++ b/src/getLocalImage.ts @@ -1,8 +1,8 @@ import { createReadStream, ReadStream } from "fs"; import { readdir } from "fs/promises"; import { exit } from "process"; -import args from "./helpers/cli.js"; -import crashHandler from "./helpers/error.js"; +import args from "./helpers/args.js"; +import crashHandler from "./helpers/crashHandler.js"; import { config } from "./helpers/types.js"; import postImage from "./postImage.js"; diff --git a/src/getRemoteImage.ts b/src/getRemoteImage.ts index 69de25d..194771b 100644 --- a/src/getRemoteImage.ts +++ b/src/getRemoteImage.ts @@ -6,8 +6,8 @@ import got from "got-cjs"; import stream from "node:stream"; import { promisify } from "node:util"; import { exit } from "process"; -import args from "./helpers/cli.js"; -import crashHandler from "./helpers/error.js"; +import args from "./helpers/args.js"; +import crashHandler from "./helpers/crashHandler.js"; import { config } from "./helpers/types.js"; import postImage from "./postImage.js"; diff --git a/src/helpers/cli.ts b/src/helpers/args.ts similarity index 100% rename from src/helpers/cli.ts rename to src/helpers/args.ts diff --git a/src/helpers/error.ts b/src/helpers/crashHandler.ts similarity index 94% rename from src/helpers/error.ts rename to src/helpers/crashHandler.ts index c08a318..81235f7 100644 --- a/src/helpers/error.ts +++ b/src/helpers/crashHandler.ts @@ -1,5 +1,5 @@ import { exit } from "process"; -import args from "./cli.js"; +import args from "./args.js"; /** * The function that gets called when the program runs into an error. diff --git a/src/helpers/config.ts b/src/helpers/getConfig.ts similarity index 88% rename from src/helpers/config.ts rename to src/helpers/getConfig.ts index 3a15f82..e27139c 100644 --- a/src/helpers/config.ts +++ b/src/helpers/getConfig.ts @@ -1,7 +1,7 @@ import { readFile } from "fs/promises"; import stripJsonComments from "strip-json-comments"; -import args from "./cli.js"; -import crashHandler from "./error.js"; +import args from "./args.js"; +import crashHandler from "./crashHandler.js"; import { config } from "./types.js"; /** @@ -9,11 +9,10 @@ import { config } from "./types.js"; * @returns The config object */ async function readConfig(): Promise { - const conf = await readFile(args.config, "utf8").catch((err) => { + return readFile(args.config, "utf8").catch((err) => { crashHandler("Error reading config file.", err); return "CRASH"; }); - return conf; } /** * Parses the config file and returns it as a JSON object diff --git a/src/index.ts b/src/index.ts index d98a928..d19c9f1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -import getConfig from "./helpers/config.js"; +import getConfig from "./helpers/getConfig.js"; import { config } from "./helpers/types.js"; import getLocalImage from "./getLocalImage.js"; import getRemoteImage from "./getRemoteImage.js"; diff --git a/src/postImage.ts b/src/postImage.ts index 47a0ed8..118956f 100644 --- a/src/postImage.ts +++ b/src/postImage.ts @@ -1,8 +1,8 @@ import { ReadStream } from "fs"; import generator, { Entity, Response } from "megalodon"; import { Readable } from "stream"; -import args from "./helpers/cli.js"; -import crashHandler from "./helpers/error.js"; +import args from "./helpers/args.js"; +import crashHandler from "./helpers/crashHandler.js"; import { config } from "./helpers/types.js"; /**