2026-07-16 17:26:23 +08:00
|
|
|
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 } = {}) {
|
2026-07-16 20:51:58 +08:00
|
|
|
return spawnSync(process.execPath, [
|
|
|
|
|
'--disable-warning=ExperimentalWarning',
|
|
|
|
|
cliEntry,
|
|
|
|
|
...args,
|
|
|
|
|
], {
|
2026-07-16 17:26:23 +08:00
|
|
|
cwd,
|
|
|
|
|
env: {
|
|
|
|
|
...process.env,
|
|
|
|
|
...(home ? { HOME: home, USERPROFILE: home } : {}),
|
|
|
|
|
...env,
|
|
|
|
|
},
|
|
|
|
|
encoding: 'utf8',
|
|
|
|
|
});
|
|
|
|
|
}
|