forked from nodegit/nodegit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.js
More file actions
25 lines (23 loc) · 634 Bytes
/
util.js
File metadata and controls
25 lines (23 loc) · 634 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
var git = require('../');
exports.makeSafe = function(object, key) {
var oldFn = object[key];
object[key] = function() {
try {
oldFn.apply(this, arguments);
} catch (e) {
var callback = arguments[arguments.length - 1];
callback(e);
}
};
};
exports.normalizeOid = function(object, key) {
var oldFn = object[key];
object[key] = function() {
var oid = arguments[0];
if (typeof oid === 'string') oid = git.Oid.fromString(oid);
var newArguments = [oid];
for (var i = 1; i < arguments.length; i++)
newArguments[i] = arguments[i];
oldFn.apply(this, newArguments);
};
};