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

fix: convert error output to be consistent cross-platform #684

Merged
merged 3 commits into from
Mar 6, 2017

Conversation

nfischer
Copy link
Member

@nfischer nfischer commented Mar 5, 2017

The error output produced by shell.error() or result.stderr should
not be inconsistent between platforms. This ensures that path separators
are always printed by ShellJS as / instead of as \ on Windows. This
should allow scripts using ShellJS to be more consistent cross-platform.

We had only one test case which relied on the old behavior, and it's in
pushd, which we don't any issues for. Since it's only the error output
that's changed, it's probably a reasonable fix to make.

Fixes #681

@nfischer nfischer added the fix Bug/defect, or a fix for such a problem label Mar 5, 2017
@nfischer nfischer added this to the v0.7.x milestone Mar 5, 2017
@nfischer nfischer requested a review from freitagbr March 5, 2017 04:27
@codecov-io
Copy link

codecov-io commented Mar 5, 2017

Codecov Report

Merging #684 into master will increase coverage by 0.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master     #684      +/-   ##
==========================================
+ Coverage    94.3%   94.32%   +0.01%     
==========================================
  Files          33       33              
  Lines        1176     1180       +4     
==========================================
+ Hits         1109     1113       +4     
  Misses         67       67
Impacted Files Coverage Δ
src/common.js 96.7% <100%> (+0.07%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fb09c6a...71f66ee. Read the comment docs.

Copy link
Contributor

@freitagbr freitagbr left a comment

Choose a reason for hiding this comment

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

I have mixed feelings about this. This is a definitely a breaking change; there might be systems out there that depend on the error output to have backslashes. It would be better to just sanitize the paths themselves, but this would be complicated to implement.

@nfischer
Copy link
Member Author

nfischer commented Mar 5, 2017

It would be better to just sanitize the paths themselves, but this would be complicated to implement.

Why would that be better? You mean to change \ ➡️ / before passing strings to commands? This would have the same effect on output.


For what it's worth, our docs don't actually specify what these error messages may be. We should decide if we really want to consider these part of our public API. In fact, shell.error() is only guaranteed to be truthy or falsy, and .stderr is only guaranteed to be some sort of error message.

The only real motivation we have for this right now is to land tests, which probably isn't enough to justify something on the fence like this. So feel free to push the milestone back to v0.8.

@freitagbr
Copy link
Contributor

I think you've convinced me. In the error messages, \ characters should only occur in the paths. And because the error messages are not documented, there should be no reason to rely on them. This looks good so I'll go ahead and merge it.

@freitagbr
Copy link
Contributor

Er, there are merge conflicts.

The error output produced by `shell.error()` or `result.stderr` should
not be inconsistent between platforms. This ensures that path separators
are always printed by ShellJS as `/` instead of as `\` on Windows. This
should allow scripts using ShellJS to be more consistent cross-platform.

We were not previously relying on error output to always be consistent--
only checking its truthiness. Since this was not part of our tested API,
it should be reasonable to change this and release in a patch.

Fixes #681
@nfischer nfischer force-pushed the fix-consistent-error-output branch from c90113d to 3940359 Compare March 6, 2017 05:58
@nfischer
Copy link
Member Author

nfischer commented Mar 6, 2017

Rebased off master. Will land this tonight.

@nfischer
Copy link
Member Author

nfischer commented Mar 6, 2017

I also fixed a TODO which depended on this being landed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug/defect, or a fix for such a problem
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error output should be consistent across all platforms.
3 participants