From 4dd98c4e26febb7aa9ed04b51cb98f815a930d13 Mon Sep 17 00:00:00 2001 From: Dominik Liebler Date: Fri, 30 Jun 2023 07:50:01 +0200 Subject: [PATCH] await command to avoid exiting before its done --- commands/FinTs.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/commands/FinTs.ts b/commands/FinTs.ts index d64a905..150fa5c 100644 --- a/commands/FinTs.ts +++ b/commands/FinTs.ts @@ -89,9 +89,18 @@ export async function runImport() { await Promise.all( accounts.map(async (account: SEPAAccount) => { + console.log(`importing ${account.iban} ...`); const transactions = await getTransactions(client, account, startDate, endDate); const affected = await insertTransactionsIntoDatabase(account, transactions); + if (affected.length > 0) { + transactions.forEach((transaction) => { + console.log( + `${transaction.description}, ${transaction.entryDate}, ${transaction.amount} ${transaction.currency}` + ); + }); + } + // TODO: report newly transmitted transactions to Discord also console.log( `import completed: ${affected.length} transactions processed for ${account.iban}` @@ -126,7 +135,7 @@ export default class FinTs extends BaseCommand { }; public async run() { - runImport(); + await runImport(); await this.exit(); }