【发布时间】:2020-10-22 06:22:29
【问题描述】:
我希望从 node.js 执行 shell 命令。我希望将标准输出显示到终端。在 python 中,我可以使用 subprocess.run 来做到这一点。在 node.js 中,我看到 child_process.exec,但这会返回 stdout 的缓冲区,而不是自动显示到终端。
【问题讨论】:
标签: python node.js terminal subprocess child-process
我希望从 node.js 执行 shell 命令。我希望将标准输出显示到终端。在 python 中,我可以使用 subprocess.run 来做到这一点。在 node.js 中,我看到 child_process.exec,但这会返回 stdout 的缓冲区,而不是自动显示到终端。
【问题讨论】:
标签: python node.js terminal subprocess child-process
就我而言,我使用child_process.execAsync 将stdio 选项设置为inherit 使其工作,如下所示:
child_process.execAsync("git push --tags", { stdio: "inherit" })
我需要 git 来显示密码提示并允许用户进行输入。
【讨论】: