Files
obelisk/tests/cli-test-helpers.mjs
T

19 lines
602 B
JavaScript
Raw Normal View History

import { spawnSync } from 'node:child_process';
import { dirname, join, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
export const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
export const cliEntry = join(repoRoot, 'packages', 'cli', 'dist', 'cli', 'src', 'obelisk.js');
export function runCli(args, { home, env = {}, cwd = repoRoot } = {}) {
return spawnSync(process.execPath, [cliEntry, ...args], {
cwd,
env: {
...process.env,
...(home ? { HOME: home, USERPROFILE: home } : {}),
...env,
},
encoding: 'utf8',
});
}