-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Refactor extra watch options regex to react-dev-utils #3362
Conversation
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.
This does not seem functionally equivalent.
.replace(/[\\]+/g, '\\\\')}).+[\\\\/]node_modules[\\\\/]`, | ||
'g' | ||
), | ||
ignored: watchOptionsRegex(paths), |
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.
We can probably pass paths.appSrc
instead of paths
.
const path = require('path'); | ||
const escapeStringRegexp = require('escape-string-regexp'); | ||
|
||
module.exports = function watchOptionsRegex(paths) { |
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'm not fond of this name, I'd like to point out these are the ignored files.
|
||
module.exports = function watchOptionsRegex(paths) { | ||
return new RegExp( | ||
`^(?!${escapeStringRegexp(path.join(paths.appSrc, '/'))}).+node_modules`, |
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.
This regex does not look identical to the old regex -- why the changes? They won't be functionally equivalent afaik.
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 this its own package now, why don't we add a few test cases to check paths that this regex should be true/false against?
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.
@Timer I added the test cases, how should they be wired up in the CI scripts?
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.
Probably just call the tests in e2e simple similar to error overlay.
Thanks for taking this on! |
Sorry, I messed up git history. Would you mind doing
Then write down hashes of your commits, do |
c59e208
to
d252e9a
Compare
@Timer I changed the regex as it was not working on windows. After digging into it, it turns out that the previous lookahead regex fails with windows path as anymatch test against both the path and the normalized version |
Seems to be broken still. I believe the reason for the wild regex (which you simplified) was cross OS support. Can you try the old one exactly? |
What is broken with the current regex? The old one did not work when I tested it on my Windows machine. It was cross OS but the regex fails in anymatch: appSrc = 'C:\\foo';
|
Thanks! |
* extra watch options regex to react-dev-utils * fix regex * add test * fix eslint error * include react-dev-utils test in CI script * attempt to fix import error * attempt to fix error on CI * Update .eslintrc
* extra watch options regex to react-dev-utils * fix regex * add test * fix eslint error * include react-dev-utils test in CI script * attempt to fix import error * attempt to fix error on CI * Update .eslintrc
* extra watch options regex to react-dev-utils * fix regex * add test * fix eslint error * include react-dev-utils test in CI script * attempt to fix import error * attempt to fix error on CI * Update .eslintrc
Refactor based on @gaearon comment