Skip to content

Commit

Permalink
fix issue with re-require()'ing native modules
Browse files Browse the repository at this point in the history
Discussion on why this change was required can be found in the following issues:

jestjs/jest#3552
jestjs/jest#3550
nodejs/node#5016
  • Loading branch information
jmurzy authored and sorenlouv committed Oct 1, 2017
1 parent bf1ff40 commit 1ddbba4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions generate/templates/templates/nodegit.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
var _ = require("lodash");
var promisify = require("promisify-node");
var rawApi;

Expand All @@ -15,6 +16,12 @@ catch (ex) {
rawApi = require("../build/Debug/nodegit.node");
}

// For disccussion on why `cloneDeep` is required, see:
// https://github.com/facebook/jest/issues/3552
// https://github.com/facebook/jest/issues/3550
// https://github.com/nodejs/node/issues/5016
rawApi = _.cloneDeep(rawApi);

// Native methods do not return an identifiable function, so we
// have to override them here
/* jshint ignore:start */
Expand Down
3 changes: 2 additions & 1 deletion lib/revwalk.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ var NodeGit = require("../");
var Revwalk = NodeGit.Revwalk;

Object.defineProperty(Revwalk.prototype, "repo", {
get: function () { return this.repository(); }
get: function () { return this.repository(); },
configurable: true
});

var _sorting = Revwalk.prototype.sorting;
Expand Down

0 comments on commit 1ddbba4

Please sign in to comment.