From 2eddce0e8392c9c22112298c75dac7db92290bc2 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Sun, 1 Aug 2021 19:52:47 +0300 Subject: [PATCH] Update format.js --- scripts/format.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/scripts/format.js b/scripts/format.js index 70c3decab3..b687eed2f0 100644 --- a/scripts/format.js +++ b/scripts/format.js @@ -1,6 +1,6 @@ -const parser = require('./parser') -const utils = require('./utils') -const log = require('./log') +const parser = require('./helpers/parser') +const utils = require('./helpers/utils') +const log = require('./helpers/log') async function main() { log.start() @@ -9,9 +9,13 @@ async function main() { let playlists = parser.parseIndex().filter(i => i.url !== 'channels/unsorted.m3u') for (const playlist of playlists) { log.print(`\nProcessing '${playlist.url}'...`) - await parser.parsePlaylist(playlist.url).then(sortChannels).then(utils.savePlaylist) + await parser + .parsePlaylist(playlist.url) + .then(sortChannels) + .then(p => p.save()) } + log.print('\n') log.finish() } @@ -19,9 +23,10 @@ async function sortChannels(playlist) { const channels = [...playlist.channels] utils.sortBy(channels, ['name', 'url']) - if (JSON.stringify(playlist.channels) !== JSON.stringify(channels)) log.print('updated') - - playlist.channels = channels + if (JSON.stringify(playlist.channels) !== JSON.stringify(channels)) { + log.print('updated') + playlist.channels = channels + } return playlist }