-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor extra watch options regex to react-dev-utils (#3362)
* 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
- Loading branch information
Showing
7 changed files
with
92 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"env": { | ||
"jest": true | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const ignoredFiles = require('../ignoredFiles'); | ||
|
||
describe('ignore watch files regex', () => { | ||
it('normal file', () => { | ||
const appSrc = '/root/src/'; | ||
const isIgnored = ignoredFiles(appSrc).test('/foo'); | ||
const isIgnoredInSrc = ignoredFiles(appSrc).test('/root/src/foo'); | ||
|
||
expect(isIgnored).toBe(false); | ||
expect(isIgnoredInSrc).toBe(false); | ||
}); | ||
|
||
it('node modules', () => { | ||
const appSrc = '/root/src/'; | ||
const isIgnored = ignoredFiles(appSrc).test('/root/node_modules/foo'); | ||
|
||
expect(isIgnored).toBe(true); | ||
}); | ||
|
||
it('node modules inside source directory', () => { | ||
const appSrc = '/root/src/'; | ||
const isIgnored = ignoredFiles(appSrc).test('/root/src/node_modules/foo'); | ||
const isIgnoredMoreThanOneLevel = ignoredFiles(appSrc).test( | ||
'/root/src/bar/node_modules/foo' | ||
); | ||
|
||
expect(isIgnored).toBe(false); | ||
expect(isIgnoredMoreThanOneLevel).toBe(false); | ||
}); | ||
|
||
it('path contains source directory', () => { | ||
const appSrc = '/root/src/'; | ||
const isIgnored = ignoredFiles(appSrc).test( | ||
'/bar/root/src/node_modules/foo' | ||
); | ||
|
||
expect(isIgnored).toBe(true); | ||
}); | ||
|
||
it('path starts with source directory', () => { | ||
const appSrc = '/root/src/'; | ||
const isIgnored = ignoredFiles(appSrc).test('/root/src2/node_modules/foo'); | ||
|
||
expect(isIgnored).toBe(true); | ||
}); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const path = require('path'); | ||
|
||
module.exports = function ignoredFiles(appSrc) { | ||
return new RegExp( | ||
`^(?!${path | ||
.normalize(appSrc + '/') | ||
.replace(/[\\]+/g, '/')}).+/node_modules/`, | ||
'g' | ||
); | ||
}; |
This file contains 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
This file contains 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
This file contains 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
This file contains 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