2022-10-06 21:14:21 +08:00
|
|
|
import type { SysCallMapping } from "../system.ts";
|
2022-03-21 22:21:34 +08:00
|
|
|
|
2022-03-25 19:03:06 +08:00
|
|
|
export default function (cwd: string): SysCallMapping {
|
2022-03-21 22:21:34 +08:00
|
|
|
return {
|
2022-04-04 00:42:12 +08:00
|
|
|
"shell.run": async (
|
2022-10-06 21:14:21 +08:00
|
|
|
_ctx,
|
2022-03-25 19:03:06 +08:00
|
|
|
cmd: string,
|
2022-10-06 21:14:21 +08:00
|
|
|
args: string[],
|
2022-03-25 19:03:06 +08:00
|
|
|
): Promise<{ stdout: string; stderr: string }> => {
|
2022-10-06 21:14:21 +08:00
|
|
|
const p = Deno.run({
|
|
|
|
cmd: [cmd, ...args],
|
2022-03-21 22:21:34 +08:00
|
|
|
cwd: cwd,
|
2022-10-06 21:14:21 +08:00
|
|
|
stdout: "piped",
|
|
|
|
stderr: "piped",
|
2022-03-21 22:21:34 +08:00
|
|
|
});
|
2022-10-06 21:14:21 +08:00
|
|
|
await p.status();
|
|
|
|
const stdout = new TextDecoder().decode(await p.output());
|
|
|
|
const stderr = new TextDecoder().decode(await p.stderrOutput());
|
|
|
|
|
2022-03-21 22:21:34 +08:00
|
|
|
return { stdout, stderr };
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|