print output of failed prepublish scripts #441#442
print output of failed prepublish scripts #441#442joaomoreno merged 1 commit intomicrosoft:masterfrom iliazeus:441-stdout-of-failed-prepublish
Conversation
|
https://github.com/iliazeus/vscode-vsce/commit/c21dcad6ca46bac1bd5b88f75e1d90abbc80571b wasn't good enough, because it caused stderr to be doubled |
| // in case of error, stderr gets written by a top-level exception handler | ||
| if (error !== undefined) throw error; | ||
| process.stderr.write(stderr); |
There was a problem hiding this comment.
Maybe also print stderr.
| // in case of error, stderr gets written by a top-level exception handler | |
| if (error !== undefined) throw error; | |
| process.stderr.write(stderr); | |
| process.stderr.write(stderr); | |
| // in case of error, stderr gets written by a top-level exception handler | |
| if (error) { | |
| throw error; | |
| } |
There was a problem hiding this comment.
Well, I don't know for sure why that happens yet, but (as I said in the comment) stderr gets printed anyway when the exception is thrown and caught somewhere on top. That is, if we print it here explicitly, it gets printed twice.
My guess is that the message of an Error that gets thrown by exec() is set to contain the stderr of a child process. Or maybe toString() of this Error gives us that.
There was a problem hiding this comment.
Welcome to Node.js v13.12.0.
Type ".help" for more information.
> const cp = require('child_process')
undefined
> let error
undefined
> void cp.exec('>&2 echo this gets printed to stderr && exit 1', e => error = e)
undefined
> error.toString()
'Error: Command failed: >&2 echo this gets printed to stderr && exit 1\n' +
'this gets printed to stderr \r\n'
> error.message
'Command failed: >&2 echo this gets printed to stderr && exit 1\n' +
'this gets printed to stderr \r\n'
|
Thanks! Ended up replacing |
This PR fixes #441