From 9aec218f128e891aae96f73967667e26c1aa5e35 Mon Sep 17 00:00:00 2001 From: theofficialomega <30985701+BellezaEmporium@users.noreply.github.com> Date: Sun, 17 Aug 2025 17:32:13 +0200 Subject: [PATCH] check if config has channels function --- scripts/commands/channels/parse.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/commands/channels/parse.ts b/scripts/commands/channels/parse.ts index 58eccd68..8ada776e 100644 --- a/scripts/commands/channels/parse.ts +++ b/scripts/commands/channels/parse.ts @@ -52,13 +52,21 @@ async function main() { }) } - let parsedChannels = config.channels(args) + let parsedChannels: epgGrabber.Channel[] | Promise = [] + + if (!config.channels || typeof config.channels !== 'function') { + logger.error(`Config file '${options.config}' does not export a channels(...) function`) + return + } + + parsedChannels = config.channels(args) + if (isPromise(parsedChannels)) { parsedChannels = await parsedChannels } - parsedChannels = parsedChannels.map((channel: epgGrabber.Channel) => { - channel.site = config.site + parsedChannels = (parsedChannels as epgGrabber.Channel[]).map((channel: epgGrabber.Channel) => { + channel.site = config.site return channel })