Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
works now when loading via nodegit, direct requires (eg require../clo…
…ne) broken
  • Loading branch information
maxkorp committed Mar 3, 2015
commit ed903e50e57a6c38224caa08d0d92ff119b19322
3 changes: 3 additions & 0 deletions generate/scripts/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,9 @@ var Helpers = {
}
}).value();

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

Expand Down
23 changes: 23 additions & 0 deletions generate/templates/templates/nodegit.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,29 @@ var importExtension = function(name) {
//must go last!
require("./enums");

/* jshint ignore:start */
{% each . as idef %}
{% if idef.type != "enum" %}
{% each idef.functions as fn %}

{% if fn.useAsOnRootProto %}
// Inherit directly from the original {{idef.jsClassName}} object.
_{{ idef.jsClassName }}.{{ fn.jsFunctionName }}.__proto__ =
_{{ idef.jsClassName }};

// Ensure we're using the correct prototype.
_{{ idef.jsClassName }}.{{ fn.jsFunctionName }}.prototype =
_{{ idef.jsClassName }}.prototype;

// Assign the function as the root
rawApi.{{idef.jsClassName}} =
_{{ idef.jsClassName }}.{{ fn.jsFunctionName }};
{% endif %}
{% endeach %}
{% endif %}
{% endeach %}
/* jshint ignore:end */

// Wrap asynchronous methods to return promises.
promisify(exports);

Expand Down