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

Refactor extra watch options regex to react-dev-utils #3362

Merged
merged 8 commits into from
Nov 4, 2017

Conversation

xjlim
Copy link
Contributor

@xjlim xjlim commented Oct 30, 2017

Refactor based on @gaearon comment

Copy link
Contributor

@Timer Timer left a 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),
Copy link
Contributor

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) {
Copy link
Contributor

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`,
Copy link
Contributor

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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.

@Timer
Copy link
Contributor

Timer commented Oct 31, 2017

Thanks for taking this on!

@Timer Timer added this to the 1.0.x milestone Oct 31, 2017
@gaearon
Copy link
Contributor

gaearon commented Oct 31, 2017

Sorry, I messed up git history. Would you mind doing

git fetch origin

Then write down hashes of your commits, do git reset --hard origin/master and cherry-pick them back onto your branch.

@xjlim xjlim force-pushed the extract-regex-to-dev-utils branch from c59e208 to d252e9a Compare October 31, 2017 11:05
@xjlim
Copy link
Contributor Author

xjlim commented Nov 2, 2017

@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

@Timer
Copy link
Contributor

Timer commented Nov 2, 2017

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?

@xjlim
Copy link
Contributor Author

xjlim commented Nov 2, 2017

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';
regex = /^(?!C:\\foo\\).+[\\/]node_modules[\\/]/
file = 'C:\\foo\\node_modules\\Test.js'

result = criterion.test(string) || altString && criterion.test(altString);
expect to be false but is true as anymatch regex is false for the first case but is true for the normalize path - C:/foo/node_modules/Test.js as this will not match the negative lookahead

@Timer
Copy link
Contributor

Timer commented Nov 4, 2017

Thanks!

@Timer Timer merged commit 36cd35d into facebook:master Nov 4, 2017
placenamehere pushed a commit to automatastudios/create-react-app that referenced this pull request Nov 30, 2017
* 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
@gaearon gaearon mentioned this pull request Jan 15, 2018
Pavek pushed a commit to Pavek/create-react-app that referenced this pull request Jul 10, 2018
* 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
zmitry pushed a commit to zmitry/create-react-app that referenced this pull request Aug 14, 2018
* 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
@lock lock bot locked and limited conversation to collaborators Jan 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants