1
0
silverbullet/plugos/syscalls/shell.node.ts

21 lines
512 B
TypeScript
Raw Normal View History

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 {
"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 };
},
};
}