Skip to content
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

Write error information to STDERR #4799

Merged
merged 3 commits into from Jun 3, 2020

Conversation

naokikimura
Copy link
Member

Which issue, if any, is this issue related to?

Closes #4798

Is there anything in the PR that needs further explanation?

No, it's self-explanatory.

Copy link
Member

@mattxwang mattxwang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems reasonable to me! Not sure if this has any other ripple effects in the ecosystem, but LGTM.

@naokikimura
Copy link
Member Author

Thank you, @malsf21

Even if there are adverse effects from this change, there is a workaround, so the ripple effect should be small.

Redirecting the standard error output to standard output as follows gives the same behavior as before.

stylelint "**/*.css" 2>&1

It's hard to separate the information once it's mixed, but it's easy to mix the information that's separated.

Copy link
Member

@m-allanson m-allanson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @naokikimura!

I've made a couple of stylistic changes while keeping your changed functionality.

This looks good to me 👍

@@ -534,10 +534,10 @@ module.exports = (argv) => {
* @returns {void}
*/
function handleError(err) {
console.log(err.stack); // eslint-disable-line no-console
process.stderr.write(err.stack);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed this from console.error to process.stderr.write. This is consistent with other errors earlier in the file, and means we can remove the // eslint-disable-line comment.

const exitCode = typeof err.code === 'number' ? err.code : 1;

process.exit(exitCode); // eslint-disable-line no-process-exit
process.exitCode = exitCode;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set an exitCode and wait for node to exit when any pending work is complete. This means we can remove another // eslint-disable-line comment. The node docs recommend against using process.exit() where possible.

@naokikimura
Copy link
Member Author

Thank you @m-allanson

I look forward to the quick release of this fix.

Copy link
Member

@jeddy3 jeddy3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM

@m-allanson m-allanson merged commit a785a30 into stylelint:master Jun 3, 2020
@m-allanson
Copy link
Member

Updated changelog:

  • Fixed: write error information to stderr (#4799).

@naokikimura naokikimura deleted the write_error_to_stderr branch June 3, 2020 12:55
iplog added a commit to iplog/ale that referenced this pull request Jan 2, 2024
Since [version 13.6.0](https://github.com/stylelint/stylelint/blob/804bb24c75248aba55b009994e4bfb561593a990/CHANGELOG.md?plain=1#L654),
following [PR 4799](stylelint/stylelint#4799)
`stylelint` errors are sent to `stderr`. Previous versions where sending
errors to `stdout`.
hsanson pushed a commit to dense-analysis/ale that referenced this pull request Jan 14, 2024
Since [version 13.6.0](https://github.com/stylelint/stylelint/blob/804bb24c75248aba55b009994e4bfb561593a990/CHANGELOG.md?plain=1#L654),
following [PR 4799](stylelint/stylelint#4799)
`stylelint` errors are sent to `stderr`. Previous versions where sending
errors to `stdout`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Fix CLI printing error information to STDOUT
4 participants