Skip to content

Commit ed903e5

Browse files
committed
works now when loading via nodegit, direct requires (eg require../clone) broken
1 parent 2542c04 commit ed903e5

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

generate/scripts/helpers.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,9 @@ var Helpers = {
324324
}
325325
}).value();
326326

327+
if ("git_" + typeDef.typeName == fnDef.cFunctionName) {
328+
fnDef.useAsOnRootProto = true;
329+
}
327330
_.merge(fnDef, _.omit(fnOverrides, "args", "return"));
328331
},
329332

generate/templates/templates/nodegit.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,29 @@ var importExtension = function(name) {
6666
//must go last!
6767
require("./enums");
6868

69+
/* jshint ignore:start */
70+
{% each . as idef %}
71+
{% if idef.type != "enum" %}
72+
{% each idef.functions as fn %}
73+
74+
{% if fn.useAsOnRootProto %}
75+
// Inherit directly from the original {{idef.jsClassName}} object.
76+
_{{ idef.jsClassName }}.{{ fn.jsFunctionName }}.__proto__ =
77+
_{{ idef.jsClassName }};
78+
79+
// Ensure we're using the correct prototype.
80+
_{{ idef.jsClassName }}.{{ fn.jsFunctionName }}.prototype =
81+
_{{ idef.jsClassName }}.prototype;
82+
83+
// Assign the function as the root
84+
rawApi.{{idef.jsClassName}} =
85+
_{{ idef.jsClassName }}.{{ fn.jsFunctionName }};
86+
{% endif %}
87+
{% endeach %}
88+
{% endif %}
89+
{% endeach %}
90+
/* jshint ignore:end */
91+
6992
// Wrap asynchronous methods to return promises.
7093
promisify(exports);
7194

0 commit comments

Comments
 (0)