-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
Make node core modules work on modulePathIgnorePatterns #122
Changes from 3 commits
db4bb08
a03e1ae
eb67eea
4fac716
cf4c6ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,7 +123,6 @@ function Loader(config, environment, resourceMap) { | |
this._reverseDependencyMap = null; | ||
this._shouldAutoMock = true; | ||
this._configShouldMockModuleNames = {}; | ||
|
||
if (_configUnmockListRegExpCache === null) { | ||
// Node must have been run with --harmony in order for WeakMap to be | ||
// available | ||
|
@@ -133,7 +132,6 @@ function Loader(config, environment, resourceMap) { | |
|
||
_configUnmockListRegExpCache = new WeakMap(); | ||
} | ||
|
||
if (!config.unmockedModulePathPatterns | ||
|| config.unmockedModulePathPatterns.length === 0) { | ||
this._unmockListRegExps = []; | ||
|
@@ -332,7 +330,6 @@ Loader.prototype._getNormalizedModuleID = function(currPath, moduleName) { | |
var moduleType; | ||
var mockAbsPath = null; | ||
var realAbsPath = null; | ||
|
||
if (this._builtInModules.hasOwnProperty(moduleName)) { | ||
moduleType = 'builtin'; | ||
realAbsPath = moduleName; | ||
|
@@ -591,9 +588,10 @@ Loader.prototype._shouldMock = function(currPath, moduleName) { | |
this._configShouldMockModuleNames[moduleName] = true; | ||
for (var i = 0; i < this._unmockListRegExps.length; i++) { | ||
unmockRegExp = this._unmockListRegExps[i]; | ||
if (unmockRegExp.test(modulePath)) { | ||
if ((unmockRegExp.test(modulePath)) || (modulePath === null)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need for the extra parenthesis, |
||
return this._configShouldMockModuleNames[moduleName] = false; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You leaked a new line here, remove it with the next commit. |
||
} | ||
return this._configShouldMockModuleNames[moduleName]; | ||
} | ||
|
@@ -687,7 +685,6 @@ Loader.prototype.getDependenciesFromPath = function(modulePath) { | |
'Could not extract dependency information from this type of file!' | ||
); | ||
} | ||
|
||
return this._getDependencyPathsFromResource(resource); | ||
}; | ||
|
||
|
@@ -836,7 +833,8 @@ Loader.prototype.requireModule = function(currPath, moduleName, | |
if (!moduleResource | ||
&& manualMockResource | ||
&& manualMockResource.path !== this._isCurrentlyExecutingManualMock | ||
&& this._explicitShouldMock[moduleID] !== false) { | ||
&& this._explicitShouldMock[moduleID] !== false | ||
&& !(moduleName in NODE_CORE_MODULES)) { | ||
modulePath = manualMockResource.path; | ||
} | ||
|
||
|
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.
Can we leave little stuff like this as-is so that git blame signal remains useful?
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.
@jeffmo addressed spacing.