diff --git a/index.ts b/index.ts index c166931..26cfb19 100644 --- a/index.ts +++ b/index.ts @@ -277,6 +277,7 @@ const run = async () => { if (IS_DRY_RUN) { logger.info("DryRun: Running in dry-run mode!"); } + const applicationConfig = getConfig(); await cloneRecyclarrTemplateRepo(); diff --git a/src/config.ts b/src/config.ts index a417c39..2284ec7 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,5 +1,6 @@ -import { readFileSync } from "fs"; +import { existsSync, readFileSync } from "fs"; import yaml from "yaml"; +import { logger } from "./logger"; import { YamlConfig } from "./types"; import { ROOT_PATH } from "./util"; @@ -24,6 +25,11 @@ export const getConfig = (): YamlConfig => { return config; } + if (!existsSync(CONFIG_LOCATION)) { + logger.error(`Config file in location "${CONFIG_LOCATION}" does not exists.`); + throw new Error("Config file not found."); + } + const file = readFileSync(CONFIG_LOCATION, "utf8"); config = yaml.parse(file, { customTags: [secretsTag] }) as YamlConfig; return config; @@ -34,6 +40,11 @@ export const getSecrets = () => { return secrets; } + if (!existsSync(SECRETS_LOCATION)) { + logger.error(`Secret file in location "${SECRETS_LOCATION}" does not exists.`); + throw new Error("Secret file not found."); + } + const file = readFileSync(SECRETS_LOCATION, "utf8"); config = yaml.parse(file); return config;