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 })