-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathcommand_submodule_update.js
More file actions
53 lines (42 loc) · 1.31 KB
/
command_submodule_update.js
File metadata and controls
53 lines (42 loc) · 1.31 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
43
44
45
46
47
48
49
50
51
52
53
'use strict';
var async = require('grunt').util.async;
var grunt = require('grunt');
module.exports = function (task, exec, done) {
var optionKey;
var allowedOptions = {
init: false,
remote: false,
force: false,
rebase: false,
merge: false,
reference: null,
depth: null,
recursive: false,
};
var options = task.options(allowedOptions);
var args = ['submodule', 'update'];
// Loop through allowable cli flags in options and add to args
for (optionKey in allowedOptions) {
if (options.hasOwnProperty(optionKey) && options[optionKey]) {
// Add flag
args.push('--' + optionKey);
// If not a boolean, add the value after the flag
if (typeof options[optionKey] !== 'boolean') {
args.push(options[optionKey]);
}
}
}
// If a path was specified, add it now:
if (options.path) {
args.push(options.path);
}
// Special handling is also needed for no-fetch option because
// of hyphen in flag: should not be used as property name
if (options.noFetch) {
args.push('--no-fetch');
}
// Add callback
args.push(done);
exec.apply(this, args);
};
module.exports.description = 'Update git submodules.';