For some reason, I cannot capture the output of the following from Yeoman's this.spawnCommand
or spawnCommandSync
method:
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:
{ 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).
I am trying to collect this information so I can bail out of my Yeoman generator.
How do I do this with 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. From what I can tell, if I don't specify any stdio
options, I should get pipes between the parent/child. Am I missing something?
Thanks!
我通过在opts中添加以下内容解决了此问题:
stdio: [process.stderr]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.