Files
actual/packages/loot-core/init-node.js
Joel Jeremy Marquez aa9c992f2e Part 2 of eslint prefer-const (#1958)
* Part 2 of eslint prefer-const

* Release notes

* Update
2023-11-22 14:28:09 -08:00

40 lines
848 B
JavaScript

import { dirname, basename } from 'path';
import fetch from 'node-fetch';
import 'source-map-support/register';
// eslint-disable-next-line import/extensions
import bundle from './lib-dist/bundle.desktop.js';
global.fetch = fetch;
async function init(budgetPath) {
const dir = dirname(budgetPath);
const budgetId = basename(budgetPath);
await bundle.initEmbedded('0.0.147', true, dir);
await bundle.lib.send('load-budget', { id: budgetId });
return bundle.lib;
}
async function run() {
const { send } = await init('/tmp/_test-budget');
const accounts = await send('accounts-get');
await send('transaction-add', {
date: '2022-03-20',
account: accounts[0].id,
amount: 1000,
});
await new Promise(resolve => {
setTimeout(() => {
resolve();
}, 5000);
});
await send('close-budget');
}
run();