为什么 deno 的 exec 包执行命令时不向终端输出消息?
Why does deno's exec package execute commands without outputting messages to the terminal?
import { exec } from "https://deno.land/x/exec/mod.ts";
await exec(`git clone https://github.com/vuejs/vue.git`)
当我在 .sh 文件中使用 git clone https://github.com/vuejs/vue.git
时,它在终端中有消息,
但在 deno
中没有
首先,我认为回显 jsejcksn :
很重要
The exec
module is not related to Deno. All modules at https://deno.land/x/...
are third-party code. For working with your shell, see Creating a subprocess in the manual.
Deno 在没有第 3 方库的情况下执行此操作的方法是使用 Deno.run
.
话虽如此,如果您查看 exec
的自述文件,您会在 Capture the output of an external command:
下找到您正在寻找的文档
Sometimes you need to capture the output of a command. For example, I do this to get git log checksums:
import { exec } from "https://deno.land/x/exec/mod.ts";
let response = await exec('git log -1 --format=%H', {output: OutputMode.Capture});
如果您查看 exec
的代码,您会发现它在幕后使用了 Deno.run
。如果您喜欢 exec
,您可以使用它,但您可能会发现您更喜欢直接使用 Deno.run
。
import { exec } from "https://deno.land/x/exec/mod.ts";
await exec(`git clone https://github.com/vuejs/vue.git`)
当我在 .sh 文件中使用 git clone https://github.com/vuejs/vue.git
时,它在终端中有消息,
但在 deno
首先,我认为回显 jsejcksn
The
exec
module is not related to Deno. All modules athttps://deno.land/x/...
are third-party code. For working with your shell, see Creating a subprocess in the manual.
Deno 在没有第 3 方库的情况下执行此操作的方法是使用 Deno.run
.
话虽如此,如果您查看 exec
的自述文件,您会在 Capture the output of an external command:
Sometimes you need to capture the output of a command. For example, I do this to get git log checksums:
import { exec } from "https://deno.land/x/exec/mod.ts"; let response = await exec('git log -1 --format=%H', {output: OutputMode.Capture});
如果您查看 exec
的代码,您会发现它在幕后使用了 Deno.run
。如果您喜欢 exec
,您可以使用它,但您可能会发现您更喜欢直接使用 Deno.run
。