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

21 lines
504 B
TypeScript
Raw Normal View History

2022-03-21 14:21:34 +00:00
import { promisify } from "util";
import { execFile } from "child_process";
2022-03-25 11:03:06 +00:00
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-03-25 11:03:06 +00:00
run: async (
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 };
},
};
}