[英]stdout/stderr not available from Yeoman/Node with spawnCommand
For some reason, I cannot capture the output of the following from Yeoman's this.spawnCommand
or spawnCommandSync
method: 由于某些原因,我无法从Yeoman的this.spawnCommand
或spawnCommandSync
方法捕获以下内容的输出:
const result = this.spawnCommandSync(
"git",
["checkout", "-b", branchName],
{
cwd: this.destinationRoot(folderName),
shell: true
}
);
console.log(result);
The output of result
shows all streams to be null, even when I do something intentionally wrong to get git to throw a "fatal" response: result
的输出显示所有流都为null,即使我故意做错了一些事情以使git抛出“致命”响应:
{ status: 128,
signal: null,
output: [ null, null, null ],
pid: 36926,
stdout: null,
stderr: null,
error: null }
My understanding is the above should catch "fatal" error messages thrown by git when a user attempts to do something (for example, clone a repo that does not exist). 我的理解是,当用户尝试执行某项操作(例如,克隆不存在的存储库)时,以上内容应捕获git抛出的“致命”错误消息。
I am trying to collect this information so I can bail out of my Yeoman generator. 我正在尝试收集此信息,以便可以从Yeoman发电机中退出。
How do I do this with Yeoman? 我应该如何用Yeoman做到这一点? Their documentation on spawnCommand and spawnCommandSync don't show much, and I get that they are just wrappers around spawn/spawn sync, which makes it more puzzling to me why the above isn't working for git commands. 他们关于spawnCommand和spawnCommandSync的文档显示不多,我知道它们只是spawn / spawn同步的包装,这使我更加困惑,为什么上面的命令不适用于git命令。 From what I can tell, if I don't specify any stdio
options, I should get pipes between the parent/child. 据我所知,如果不指定任何stdio
选项,则应该在父/子之间获得管道。 Am I missing something? 我想念什么吗?
Thanks! 谢谢!
我通过在opts中添加以下内容解决了此问题:
stdio: [process.stderr]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.