Skip to content

Commit 37b3b90

Browse files
committed
remove module.exports and move stuff around A LOT
1 parent 78ea4b7 commit 37b3b90

33 files changed

+79
-119
lines changed

generate/templates/templates/nodegit.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
var Promise = require("nodegit-promise");
22
var promisify = require("promisify-node");
3+
var path = require("path");
4+
var local = path.join.bind(path, __dirname);
35
var rawApi;
46

57
// Attempt to load the production release first, if it fails fall back to the
@@ -52,20 +54,32 @@ exports.__proto__ = rawApi;
5254

5355
var importExtension = function(name) {
5456
try {
55-
require("./" + name);
56-
} catch (unhandledException) {}
57+
require(local(name));
58+
}
59+
catch (unhandledException) {
60+
if (unhandledException.code != "MODULE_NOT_FOUND") {
61+
throw unhandledException;
62+
}
63+
}
5764
};
5865

66+
// Load up utils
67+
rawApi.Utils = {};
68+
require(local("utils", "lookup_wrapper"));
69+
require(local("utils", "normalize_options"));
70+
71+
// Load up extra types;
72+
require(local("convenient_hunk"));
73+
require(local("convenient_patch"));
74+
require(local("status_file"));
75+
require(local("enums.js"));
76+
5977
// Import extensions
6078
{% each %}
6179
{% if type != "enum" %}
6280
importExtension("{{ filename }}");
6381
{% endif %}
6482
{% endeach %}
65-
66-
//must go last!
67-
require("./enums");
68-
6983
/* jshint ignore:start */
7084
{% each . as idef %}
7185
{% if idef.type != "enum" %}

lib/attr.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

lib/blob.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
var NodeGit = require("../");
2-
var TreeEntry = require("./tree_entry");
3-
var LookupWrapper = require("./util/lookupWrapper");
4-
52
var Blob = NodeGit.Blob;
3+
var LookupWrapper = NodeGit.Utils.lookupWrapper;
4+
var TreeEntry = NodeGit.TreeEntry;
5+
66

77
/**
88
* Retrieves the blob pointed to by the oid
@@ -41,5 +41,3 @@ Blob.prototype.filemode = function() {
4141

4242
return this.isBinary() ? FileMode.EXECUTABLE : FileMode.BLOB;
4343
};
44-
45-
module.exports = Blob;

lib/branch.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

lib/checkout.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
var NodeGit = require("../");
2-
var normalizeOptions = require("./util/normalize_options");
2+
var normalizeOptions = NodeGit.Utils.normalizeOptions;
33

44
var Checkout = NodeGit.Checkout;
55
var head = Checkout.head;
@@ -33,5 +33,3 @@ Checkout.tree = function(repo, treeish, options) {
3333

3434
return tree.call(this, repo, treeish, options);
3535
};
36-
37-
module.exports = Checkout;

lib/clone.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
var NodeGit = require("../");
2-
var normalizeOptions = require("./util/normalize_options");
2+
var normalizeOptions = NodeGit.Utils.normalizeOptions;
33

44
var Clone = NodeGit.Clone;
55
var clone = Clone.clone;
@@ -44,5 +44,3 @@ Clone.clone = function(url, local_path, options) {
4444
.then(freeRepository)
4545
.then(openRepository);
4646
};
47-
48-
module.exports = Clone.clone;

lib/commit.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
var events = require("events");
22
var Promise = require("nodegit-promise");
33
var NodeGit = require("../");
4-
var LookupWrapper = require("./util/lookupWrapper");
5-
64
var Commit = NodeGit.Commit;
5+
var LookupWrapper = NodeGit.Utils.lookupWrapper;
76

87
/**
98
* Retrieves the commit pointed to by the oid
@@ -207,5 +206,3 @@ Commit.prototype.getDiff = function(callback) {
207206
Commit.prototype.toString = function() {
208207
return this.sha();
209208
};
210-
211-
module.exports = Commit;

lib/convenient_hunk.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
var NodeGit = require("../");
2+
13
function ConvenientHunk(raw, i) {
24
this.raw = raw;
35
this.i = i;
@@ -32,4 +34,4 @@ ConvenientHunk.prototype.lines = function() {
3234
return result;
3335
};
3436

35-
module.exports = ConvenientHunk;
37+
NodeGit.ConvenientHunk = ConvenientHunk;

lib/convenient_patch.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
var git = require("../");
2-
var Diff = git.Diff;
3-
var ConvenientHunk = require("./convenient_hunk");
1+
var NodeGit = require("../");
2+
var Diff = NodeGit.Diff;
3+
var ConvenientHunk = NodeGit.ConvenientHunk;
44

55
function ConvenientPatch(delta, patch) {
66
this.delta = delta;
77
this.patch = patch;
88
}
99

10-
1110
/**
1211
* Old name of the file
1312
* @return {String}
@@ -126,4 +125,4 @@ ConvenientPatch.prototype.isTypeChange = function() {
126125
return this.status() == Diff.DELTA.TYPECHANGE;
127126
};
128127

129-
module.exports = ConvenientPatch;
128+
NodeGit.ConvenientPatch = ConvenientPatch;

lib/diff.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
var NodeGit = require("../");
2-
var Patch = require("./patch");
3-
var ConvenientPatch = require("./convenient_patch");
4-
var normalizeOptions = require("./util/normalize_options");
5-
62
var Diff = NodeGit.Diff;
3+
var ConvenientPatch = NodeGit.ConvenientPatch;
4+
var normalizeOptions = NodeGit.Utils.normalizeOptions;
5+
var Patch = NodeGit.Patch;
6+
77

88
/**
99
* Retrieve patches in this difflist
@@ -62,5 +62,3 @@ Diff.prototype.findSimilar = function(opts) {
6262
opts = normalizeOptions(opts, NodeGit.DiffFindOptions);
6363
return findSimilar.call(this, opts);
6464
};
65-
66-
module.exports = Diff;

0 commit comments

Comments
 (0)