Change server-side shell running implementation

This commit is contained in:
Zef Hemel
2023-12-17 15:25:44 +01:00
parent 7bd58ae0e8
commit b3d5af360b
5 changed files with 23 additions and 26 deletions
-24
View File
@@ -1,24 +0,0 @@
import { ShellResponse } from "../../server/rpc.ts";
import type { SysCallMapping } from "../system.ts";
export function shellSyscalls(cwd: string): SysCallMapping {
return {
"shell.run": async (
_ctx,
cmd: string,
args: string[],
): Promise<ShellResponse> => {
const p = new Deno.Command(cmd, {
args: args,
cwd,
stdout: "piped",
stderr: "piped",
});
const output = await p.output();
const stdout = new TextDecoder().decode(output.stdout);
const stderr = new TextDecoder().decode(output.stderr);
return { stdout, stderr, code: output.code };
},
};
}