mirror of
https://github.com/merlinhu1/truthmark.git
synced 2026-08-25 07:53:25 +02:00
18 lines
686 B
TypeScript
18 lines
686 B
TypeScript
import { execa } from "execa";
|
|
import path from "node:path";
|
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
|
|
const workspaceRoot = path.resolve(fileURLToPath(new URL("../../", import.meta.url)));
|
|
const cliEntrypoint = path.resolve(
|
|
fileURLToPath(new URL("../../src/cli/main.ts", import.meta.url)),
|
|
);
|
|
const tsxLoader = pathToFileURL(
|
|
path.resolve(fileURLToPath(new URL("../../node_modules/tsx/dist/loader.mjs", import.meta.url))),
|
|
).href;
|
|
|
|
export const runCli = async (args: string[], options: { cwd?: string } = {}) => {
|
|
return execa(process.execPath, ["--import", tsxLoader, cliEntrypoint, ...args], {
|
|
cwd: options.cwd ?? workspaceRoot,
|
|
reject: false,
|
|
});
|
|
}; |