Skip to content

Commit 1ddbba4

Browse files
jmurzysorenlouv
authored andcommitted
fix issue with re-require()'ing native modules
Discussion on why this change was required can be found in the following issues: jestjs/jest#3552 jestjs/jest#3550 nodejs/node#5016
1 parent bf1ff40 commit 1ddbba4

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

generate/templates/templates/nodegit.js

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
var _ = require("lodash");
12
var promisify = require("promisify-node");
23
var rawApi;
34

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

19+
// For disccussion on why `cloneDeep` is required, see:
20+
// https://github.com/facebook/jest/issues/3552
21+
// https://github.com/facebook/jest/issues/3550
22+
// https://github.com/nodejs/node/issues/5016
23+
rawApi = _.cloneDeep(rawApi);
24+
1825
// Native methods do not return an identifiable function, so we
1926
// have to override them here
2027
/* jshint ignore:start */

lib/revwalk.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ var NodeGit = require("../");
22
var Revwalk = NodeGit.Revwalk;
33

44
Object.defineProperty(Revwalk.prototype, "repo", {
5-
get: function () { return this.repository(); }
5+
get: function () { return this.repository(); },
6+
configurable: true
67
});
78

89
var _sorting = Revwalk.prototype.sorting;

0 commit comments

Comments
 (0)