-
Notifications
You must be signed in to change notification settings - Fork 82
Expand file tree
/
Copy pathcommand_clone.js
More file actions
51 lines (41 loc) · 1.21 KB
/
Copy pathcommand_clone.js
File metadata and controls
51 lines (41 loc) · 1.21 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
'use strict';
var async = require('grunt').util.async;
var grunt = require('grunt');
module.exports = function (task, exec, done) {
var options = task.options({
bare: false,
branch: false,
repository: false,
directory: false
});
// repo directory exists
if(grunt.file.exists(options.directory ? options.directory : task.target)){
grunt.log.ok(task.target+' exists!');
return done(); // call next
}
var args = ['clone'];
// repo is the sole required option
if (!options.repository) {
done(new Error('gitclone tasks requires that you specify a "repository"'));
return;
}
if (options.bare) {
args.push('--bare');
}
if (options.branch && !options.bare) {
args.push('--branch');
args.push(options.branch);
}
// repo comes after the options
args.push(options.repository);
// final argument is checkout directory (optional)
if (options.directory) {
args.push(options.directory);
}else{// use task target name
args.push(task.target);
}
// Add callback
args.push(done);
exec.apply(this, args);
};
module.exports.description = 'Clone repositories.';