-
Notifications
You must be signed in to change notification settings - Fork 799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't fail on stderr output, but print the output to stderr #110
Conversation
I suspect coverage decrease is because the actual amount of code went down, since the |
@@ -108,6 +108,17 @@ function outputChangelog (argv, cb) { | |||
}) | |||
} | |||
|
|||
function handleExecError (err, stderr) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we should handle err
and stderr
differently?
the problem is with stderr
shouldn't terminate the program. But for err
we keep the same behaviour. No?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I misread your code. It LGTM now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to test exit code for all different scenarios?
You can check out the coverage output and see why |
// If exec returns an error or content in stderr, log it and exit with return code 1 | ||
var errMessage = stderr || (err && err.message) | ||
if (errMessage) { | ||
console.error(chalk.red(errMessage)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think when err
is null, better to use console.warn
to output the error message. Red message means real error.
Since console.error/warn's output will have its own color, should it continue to use chalk
to control the color?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since console.error/warn's output will have its own color
I don't think so
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The console.warn() function is an alias for console.error().
https://nodejs.org/api/console.html#console_console_warn_data
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should print to stderr
(console.error
), but how about yellow color for when the exit code was 0?
Since console.error/warn's output will have its own color, should it continue to use chalk to control the color?
AFAIK chalk should handle coloring the output correctly regardless of the stream it will be printed to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry for my poor knowledge, yellow would be great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 458da35
What do you mean by this? What scenarios should we be checking for? One thing that is missing, is rolling back changes made by
Thanks! Yeah, the missed line count stayed the same at 4, but overall line count went down. Should actually find out what is not being tested.. I'll get to it soon, as I'll have some time. |
Nice work! @Tapppi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code logic could be more clear
var errMessage = stderr || (err && err.message) | ||
if (errMessage) { | ||
console.error(chalk.red(errMessage)) | ||
console.error(err ? chalk.red(errMessage) : chalk.yellow(errMessage)) | ||
if (err) { | ||
process.exit(1) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Tapppi , i think it would be better to be:
if (err) {
console.error(chalk.red(stderr || err.message))
process.exit(1)
} else if(stderr) {
console.warn(chalk.yellow(stderr))
}
the prior stderr
in console.error
could be dropped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, changed in 6338f32
6cf3cbd
to
6338f32
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@Tapppi looks good to me land it. |
when will this fix release? coz now it's some kind of blocking bug. |
a beta release is welcomed too. |
@bcoe could you publish this? |
For #91, this would stop
standard-version
from failing fast whengit
or hooks or something prints tostderr
, but prints it out. Added test case it for as well. Also, errors are now printed tostderr/console.error
instead ofstdout/console.log
./CC @nexdrew @duclet @e-cloud @stevemao @bcoe