2022-04-05 15:02:17 +00:00
|
|
|
import { promisify } from "util";
|
|
|
|
import { execFile } from "child_process";
|
|
|
|
import type { SysCallMapping } from "../system";
|
2022-03-21 14:21:34 +00:00
|
|
|
|
|
|
|
const execFilePromise = promisify(execFile);
|
|
|
|
|
2022-03-25 11:03:06 +00:00
|
|
|
export default function (cwd: string): SysCallMapping {
|
2022-03-21 14:21:34 +00:00
|
|
|
return {
|
2022-04-03 16:42:12 +00:00
|
|
|
"shell.run": async (
|
2022-03-25 11:03:06 +00:00
|
|
|
ctx,
|
|
|
|
cmd: string,
|
|
|
|
args: string[]
|
|
|
|
): Promise<{ stdout: string; stderr: string }> => {
|
2022-03-21 14:21:34 +00:00
|
|
|
let { stdout, stderr } = await execFilePromise(cmd, args, {
|
|
|
|
cwd: cwd,
|
|
|
|
});
|
|
|
|
return { stdout, stderr };
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|