0

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!

Elliot Rodriguez
  • 608
  • 6
  • 25

1 Answers1

0

I resolved this by adding the following to opts:

stdio: [process.stderr]

Elliot Rodriguez
  • 608
  • 6
  • 25