ci/woodpecker/pr/config Pipeline was successful
ci/woodpecker/pr/hledger Pipeline was successful
ci/woodpecker/pr/jobs Pipeline was successful
ci/woodpecker/pr/snapshots Pipeline was successful
ci/woodpecker/pr/web Pipeline was successful
ci/woodpecker/pr/worker Pipeline was successful
ci/woodpecker/push/config Pipeline was successful
ci/woodpecker/push/hledger Pipeline was successful
ci/woodpecker/push/jobs Pipeline was successful
ci/woodpecker/push/snapshots Pipeline was successful
ci/woodpecker/push/web Pipeline was successful
ci/woodpecker/push/worker Pipeline was successful
42 lines
1.3 KiB
JavaScript
42 lines
1.3 KiB
JavaScript
import { spawn } from 'node:child_process';
|
|
import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises';
|
|
import { tmpdir } from 'node:os';
|
|
import { join } from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { lotsJournal } from './journal.ts';
|
|
|
|
// One fixture inspection, not a persistent deployment or a worker/web launcher.
|
|
const directory = await mkdtemp(join(tmpdir(), 'hledger-worker-inspect-'));
|
|
try {
|
|
const config = join(directory, 'config', 'hledger-reports.json');
|
|
await mkdir(join(directory, 'config'));
|
|
await writeFile(join(directory, 'source.journal'), lotsJournal);
|
|
await writeFile(
|
|
config,
|
|
JSON.stringify({
|
|
version: 1,
|
|
journal: '../source.journal',
|
|
url: { app: 'http://127.0.0.1:3000' },
|
|
auth: { credentials: { username: 'fixture', password: '${AUTH_PASSWORD}' } }
|
|
})
|
|
);
|
|
const child = spawn(
|
|
process.execPath,
|
|
[
|
|
'--conditions=development',
|
|
'--import',
|
|
new URL('../../../tools/register.js', import.meta.url).href,
|
|
fileURLToPath(new URL('../src/inspect.ts', import.meta.url)),
|
|
'--config',
|
|
config
|
|
],
|
|
{ stdio: 'inherit' }
|
|
);
|
|
process.exitCode = await new Promise((resolve, reject) => {
|
|
child.once('error', reject);
|
|
child.once('close', (code) => resolve(code ?? 1));
|
|
});
|
|
} finally {
|
|
await rm(directory, { recursive: true, force: true });
|
|
}
|