From 465d38abb9d025a9c6b1d3f1c3d756a9a69fac37 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Fri, 21 Jan 2022 17:00:04 +0300 Subject: [PATCH] Update create-database.js --- scripts/commands/create-database.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/commands/create-database.js b/scripts/commands/create-database.js index 59dd66bf..5697dcd3 100644 --- a/scripts/commands/create-database.js +++ b/scripts/commands/create-database.js @@ -13,23 +13,21 @@ const options = program .parse(process.argv) .opts() -const channels = [] - async function main() { logger.info('Starting...') logger.info(`Number of clusters: ${options.maxClusters}`) - await loadChannels() - await saveToDatabase() + await saveToDatabase(await getChannels()) logger.info('Done') } main() -async function loadChannels() { +async function getChannels() { logger.info(`Loading channels...`) + const channels = [] const files = await file.list(options.channels) for (const filepath of files) { const dir = file.dirname(filepath) @@ -51,9 +49,11 @@ async function loadChannels() { } } logger.info(`Found ${channels.length} channels`) + + return channels } -async function saveToDatabase() { +async function saveToDatabase(channels = []) { logger.info('Saving to the database...') await db.channels.load() await db.channels.reset()