forked from nodegit/nodegit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilter_registry.js
More file actions
42 lines (35 loc) · 1.13 KB
/
filter_registry.js
File metadata and controls
42 lines (35 loc) · 1.13 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
var NodeGit = require("../");
var normalizeOptions = NodeGit.Utils.normalizeOptions;
var FilterRegistry = NodeGit.FilterRegistry;
var _register = FilterRegistry.register;
var _unregister = FilterRegistry.unregister;
// register should add filter by name to dict and return
// Override FilterRegistry.register to normalize Filter
FilterRegistry.register = function(name, filter, priority, callback) {
// setting default value of attributes
if (filter.attributes === undefined) {
filter.attributes = "";
}
filter = normalizeOptions(filter, NodeGit.Filter);
if (!filter.check || !filter.apply) {
return callback(new Error(
"ERROR: please provide check and apply callbacks for filter"
));
}
return _register(name, filter, priority)
.then(function(result) {
if (typeof callback === "function") {
callback(null, result);
}
return result;
}, callback);
};
FilterRegistry.unregister = function(name, callback) {
return _unregister(name)
.then(function(result) {
if (typeof callback === "function") {
callback(null, result);
}
return result;
}, callback);
};