Skip to content
This repository has been archived by the owner on Apr 26, 2018. It is now read-only.

Commit

Permalink
Only add __set__ and __get__ methods if module.exports is an extensib…
Browse files Browse the repository at this point in the history
…le object
  • Loading branch information
shebson committed Aug 14, 2015
1 parent 8fed346 commit 49c7888
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ module.exports = function rewireify(file, options) {

function end() {
post += "/* This code was injected by Rewireify */\n";
post += "if (typeof module.exports === 'object' && Object.isExtensible(module.exports)) {\n";
post += "Object.defineProperty(module.exports, '__get__', { value: " + __get__ + ", writable: true });\n";
post += "Object.defineProperty(module.exports, '__set__', { value: " + __set__ + ", writable: true });\n";
post += "}\n";

this.queue(data);
this.queue(post);
Expand Down

0 comments on commit 49c7888

Please sign in to comment.