你需要阅读
p.stdout
和
p.stderr
,两者都是
FsFile
这样你就可以使用
.readable
访问
ReadableStream
或使用
.read
方法
FsFile
const myCMD = `/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome`;
const p = Deno.run({
cmd: [
myCMD,
"--remote-debugging-port=9222",
"--no-first-run",
"--no-default-browser-check",
"--user-data-dir=$(mktemp -d -t 'chrome-remote_data_dir')",
],
stdout: "piped",
stderr: "piped",
stdin: "piped",
});
(async() => {
for await(const chunk of p.stdout.readable) {
console.log(chunk, new TextDecoder().decode(chunk))
}
})();
(async() => {
for await(const chunk of p.stderr.readable) {
console.log(chunk, new TextDecoder().decode(chunk))
}
})();
await p.stdin.write(new TextEncoder().encode("Coming from stdin\n"));
await p.status();
现在您将看到该过程的输出。