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

Make node core modules work on modulePathIgnorePatterns #122

Closed
wants to merge 5 commits into from
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/HasteModuleLoader/HasteModuleLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ function Loader(config, environment, resourceMap) {
this._reverseDependencyMap = null;
this._shouldAutoMock = true;
this._configShouldMockModuleNames = {};

if (_configUnmockListRegExpCache === null) {
Copy link
Contributor

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?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeffmo addressed spacing.

// Node must have been run with --harmony in order for WeakMap to be
// available
Expand All @@ -133,7 +132,6 @@ function Loader(config, environment, resourceMap) {

_configUnmockListRegExpCache = new WeakMap();
}

if (!config.unmockedModulePathPatterns
|| config.unmockedModulePathPatterns.length === 0) {
this._unmockListRegExps = [];
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for the extra parenthesis, if (unmockRegExp.test(modulePath) || modulePath === null) { works as well

return this._configShouldMockModuleNames[moduleName] = false;
}

Copy link

Choose a reason for hiding this comment

The 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];
}
Expand Down Expand Up @@ -687,7 +685,6 @@ Loader.prototype.getDependenciesFromPath = function(modulePath) {
'Could not extract dependency information from this type of file!'
);
}

return this._getDependencyPathsFromResource(resource);
};

Expand Down Expand Up @@ -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;
}

Expand Down