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 path issues with source maps #117

Merged
merged 1 commit into from
Feb 20, 2015

Conversation

riaann
Copy link
Contributor

@riaann riaann commented Feb 17, 2015

On Windows, node's path api returns backslashes for path separators.

Because the source-map library expects forward slashes in all cases, their relative path logic (specifically their "normalize" function) gives incorrect results when passing in backslash. The mozilla/source-map library won't change this, because they are actually expecting URLs as input - see mozilla/source-map#91 (comment).

This fix is similar to the one made for grunt-contrib-uglify: gruntjs/grunt-contrib-uglify#175.

Fixes #95.

@XhmikosR
Copy link
Member

@vladikoff: can you add Appveyor properly? This is supposed to fix the Windows issue yet we can't check automatically.

@riaann: I still get 5 failures, the same failures we get on master https://ci.appveyor.com/project/gruntjs/grunt-contrib-concat/build/job/k0laci6yydq2q5fb

@XhmikosR XhmikosR added the bug label Feb 17, 2015
@riaann
Copy link
Contributor Author

riaann commented Feb 17, 2015

@XhmikosR: Thanks, I'll have a look at those tests and report back.

@riaann
Copy link
Contributor Author

riaann commented Feb 17, 2015

The unit tests now all pass on my (Windows) machine. I hope Appveyor agrees! 😃

@XhmikosR
Copy link
Member

@riaann: unfortunately, AppVeyor isn't set up properly yet for this repo so we don't have it for PRs. But the tests seem to pass so gj!

PS. Please squash those 2 patches into one.

On windows, node's path api returns backslashes for path separators.
Because the source-map library expects forward slashes in all cases,
their relative path logic (specifically their "normalize" function)
gives incorrect results when passing in backslash.  The
mozilla/source-map library won't change this, because they are actually
expecting URLs as input - see
mozilla/source-map#91 (comment).

This fix is similar to the one made for grunt-contrib-uglify:
gruntjs/grunt-contrib-uglify#175.

Standardized line endings for test fixtures by enforcing LF end of files for fixtures directory
(through repository .gitattributes).  This change was needed
because the expected output of source maps are based on input files with LF, rather
than CRLF. Before this change the tests were breaking due to git autocrlf on Windows.
The difference between the source maps generated from input
files using CRLF and the source maps generated from input files using
only LF can't be normalized in the test, due to the nature of the
changes:  the offsets in the source map are changed, as well as the
embedded source.  These kinds of changes aren't as simple to normalize
as just line feeds in output files - and such normalization would be too
invasive, to the point of making the test less effective.

This should fix issue gruntjs#110 and gruntjs#95 and all unit tests should now pass.
@riaann
Copy link
Contributor Author

riaann commented Feb 18, 2015

I have squashed the commits, and consolidated the commit message.

@XhmikosR
Copy link
Member

@vladikoff: we really need AppVeyor set up properly so that the PRs are handled too.

/CC @sindresorhus for review too.

Things seem to work fine from my tests so far.

@vladikoff
Copy link
Member

@XhmikosR fixed!

@XhmikosR
Copy link
Member

@vladikoff: thanks! Too bad only owners can trigger a new build :/

@XhmikosR
Copy link
Member

@riaann
Copy link
Contributor Author

riaann commented Feb 19, 2015

Unfortunately, we can't use that library, because it sometimes keeps the
backslashes (with the intention of keeping the path a valid Windows path).
In our case, the path should be turned into a relative URL, so we must
always convert to forward slashes.

Do you agree?
On 18 Feb 2015 7:15 PM, "XhmikosR" notifications@github.com wrote:

@riaann https://github.com/RiaanN @sindresorhus
https://github.com/sindresorhus: how about using
https://github.com/sindresorhus/slash?


Reply to this email directly or view it on GitHub
#117 (comment)
.

@sindresorhus
Copy link
Member

Yes, @riaann is right.

@XhmikosR
Copy link
Member

OK, cool. How about this PR itself then @sindresorhus?

sindresorhus added a commit that referenced this pull request Feb 20, 2015
Fix path issues with source maps
@sindresorhus sindresorhus merged commit 0bd3211 into gruntjs:master Feb 20, 2015
@riaann riaann deleted the path-separator-fix branch February 20, 2015 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong paths in source maps
4 participants