1
0
silverbullet/plugos/syscalls/shell.node.ts
Zef Hemel 561aa6891f
Migrate to Deno (#86)
Big bang migration to Deno 🤯
2022-10-10 14:50:21 +02:00

24 lines
596 B
TypeScript

import type { SysCallMapping } from "../system.ts";
export default function (cwd: string): SysCallMapping {
return {
"shell.run": async (
_ctx,
cmd: string,
args: string[],
): Promise<{ stdout: string; stderr: string }> => {
const p = Deno.run({
cmd: [cmd, ...args],
cwd: cwd,
stdout: "piped",
stderr: "piped",
});
await p.status();
const stdout = new TextDecoder().decode(await p.output());
const stderr = new TextDecoder().decode(await p.stderrOutput());
return { stdout, stderr };
},
};
}