Skip to content

Commit

Permalink
await command to avoid exiting before its done
Browse files Browse the repository at this point in the history
  • Loading branch information
domnikl committed Jun 30, 2023
1 parent 04564c3 commit 4dd98c4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion commands/FinTs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
Expand Down Expand Up @@ -126,7 +135,7 @@ export default class FinTs extends BaseCommand {
};

public async run() {
runImport();
await runImport();

await this.exit();
}
Expand Down

0 comments on commit 4dd98c4

Please sign in to comment.