Skip to content

Commit

Permalink
Only copy undefined module keys, not all falsy ones
Browse files Browse the repository at this point in the history
  • Loading branch information
bendrucker committed Mar 2, 2015
1 parent dd77d2a commit 16f66f3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/proxyquire.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function fillMissingKeys(mdl, original) {
if (is.Object(original) || is.Function(original)) {
// fill in keys for all objects
Object.keys(original).forEach(function (key) {
if (!mdl[key]) mdl[key] = original[key];
if (typeof mdl[key] === 'undefined') mdl[key] = original[key];
});
}
return mdl;
Expand Down

6 comments on commit 16f66f3

@bendrucker
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@thlorenz This should go out in a patch release when you have a chance. Fixes the iojs issue with fs without needing to check the property descriptor.

@thlorenz
Copy link
Owner

Choose a reason for hiding this comment

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

Thinking about this, this would break if someone was trying to simulate that a value is actually undefined.
Maybe it'd be better to have some better way of detecting if a property exists on the object or any of it's prototypes, even if it's undefined.

@thlorenz
Copy link
Owner

Choose a reason for hiding this comment

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

At any rate it's an improvement and I'll pull it in and publish.

@thlorenz
Copy link
Owner

Choose a reason for hiding this comment

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

Published - thanks :)

@bendrucker
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That would be for key in mdl then. Wanna do that?

@thlorenz
Copy link
Owner

Choose a reason for hiding this comment

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

Well as long as it works with prototype chain. That was basically something I wasn't/am not sure of.

Please sign in to comment.