fix failed tests on Windows #8737#8747
Merged
gaearon merged 5 commits intofacebook:masterfrom Jan 12, 2017
jddxf:fix-failed-tests-on-windows
Merged
fix failed tests on Windows #8737#8747gaearon merged 5 commits intofacebook:masterfrom jddxf:fix-failed-tests-on-windows
gaearon merged 5 commits intofacebook:masterfrom
jddxf:fix-failed-tests-on-windows
Conversation
gaearon
reviewed
Jan 11, 2017
| filename = path.normalize(filename); | ||
| var reactRegex = new RegExp( | ||
| path.join('/', '(?:React|ReactDOM)(?:\.d)?\.ts$') | ||
| '\\' + path.join('/', '(?:React|ReactDOM)(?:\.d)?\.ts$') |
Collaborator
There was a problem hiding this comment.
Can you explain why this helps exactly? There is a comment right above:
// `path.normalize` and `path.join` are used to turn forward slashes in
// the file path into backslashes on Windows.Are they not helping? Why?
Ideally I’d like to see us use one separator style, and normalize paths when necessary.
Contributor
Author
There was a problem hiding this comment.
They help to normalize the path.But we need more work to construct a RegExp instance.
The backslash added here is to escape the leading separator, which is an special character in regular expression.
Oh,Wait.All of a sudden, I find the dots need to be escaped too.So I'll change it to:
var reactRegex = new RegExp(
path.join('/', '(?:React|ReactDOM)(?:\.d)?\.ts$')
.replace(/[\\.]/g, '\\$&')
);
Or more simple, if we don't mind matching files like XXXReact.d.ts:
var reactRegex = /(?:React|ReactDOM)(?:\.d)?\.ts$/;
@gaearon Which do you think would be better?
…eed to bother with escaping special character like `\` and `.`. Note that by removing the path separator in regexp, I've relaxed the matching condition a little.Since there's little chance we have files like `XXXReact.d.ts`,it should not matter.
Collaborator
|
Thank you for fixing this! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

No description provided.