Slide 24
Slide 24 text
Copyright (C) 2024 Toranoana Lab Inc. All Rights Reserved.
作ったもの紹介
● まだ古い…
24
export async function runCommand(
cmd: string[],
options: Record = {},
) {
const process = new Deno.Command(cmd[0], {
args: cmd.slice(1),
stdout: "piped",
stderr: "piped",
...options,
}).spawn();
const { success, stdout, stderr } = await process.output();
if (success) {
const output = new TextDecoder().decode(stdout);
console.log(output);
} else {
const error = new TextDecoder().decode(stderr);
console.error(error);
}
}