From 781e2f540fc93e4da912e41bf0296a3eff0ad281 Mon Sep 17 00:00:00 2001 From: Eduard Marbach Date: Mon, 1 Apr 2024 10:07:00 +0200 Subject: [PATCH] fix: check if local cf path exist --- src/custom-formats.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/custom-formats.ts b/src/custom-formats.ts index 2de41c5..09105eb 100644 --- a/src/custom-formats.ts +++ b/src/custom-formats.ts @@ -1,4 +1,4 @@ -import { readdirSync } from "fs"; +import fs, { readdirSync } from "fs"; import path from "path"; import { CustomFormatResource } from "./__generated__/generated-sonarr-api"; import { getArrApi } from "./api"; @@ -91,6 +91,12 @@ export const loadLocalCfs = async (): Promise => { } const cfPath = path.resolve(config.localCustomFormatsPath); + + if (!fs.existsSync(cfPath)) { + console.log(`Provided local custom formats path '${config.localCustomFormatsPath}' does not exist.`); + return null; + } + const files = readdirSync(`${cfPath}`).filter((fn) => fn.endsWith("json")); const carrIdToObject = new Map(); const cfNameToCarrObject = new Map();