forked from nodegit/nodegit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubmodule.js
More file actions
40 lines (32 loc) · 1.14 KB
/
submodule.js
File metadata and controls
40 lines (32 loc) · 1.14 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
var NodeGit = require("../");
var normalizeFetchOptions = NodeGit.Utils.normalizeFetchOptions;
var normalizeOptions = NodeGit.Utils.normalizeOptions;
var shallowClone = NodeGit.Utils.shallowClone;
var Submodule = NodeGit.Submodule;
var _foreach = Submodule.foreach;
var _update = Submodule.prototype.update;
// Override Submodule.foreach to eliminate the need to pass null payload
Submodule.foreach = function(repo, callback) {
return _foreach(repo, callback, null);
};
/**
* Updates a submodule
*
* @async
* @param {Number} init Setting this to 1 will initialize submodule
* before updating
* @param {SubmoduleUpdateOptions} options Submodule update settings
* @return {Number} 0 on success, any non-zero return value from a callback
*/
Submodule.prototype.update = function(init, options) {
var fetchOpts = normalizeFetchOptions(options && options.fetchOpts);
if (options) {
options = shallowClone(options);
delete options.fetchOpts;
}
options = normalizeOptions(options, NodeGit.SubmoduleUpdateOptions);
if (options) {
options.fetchOpts = fetchOpts;
}
return _update.call(this, init, options);
};