-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
44 lines (36 loc) · 914 Bytes
/
index.js
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
'use strict';
var path = require('path');
var Input = require('prompt-input');
var clone = require('gh-clone');
module.exports = function(options, cb) {
var opts = Object.assign({}, options);
if (typeof options === 'function') {
cb = options;
options = {};
}
if (typeof cb !== 'function') {
throw new TypeError('expected callback to be a function');
}
var question = Object.assign({
name: 'clone',
message: 'GitHub repo to clone? (owner/name)'
}, opts);
var prompt = new Input(question);
setImmediate(function() {
prompt.ask(function(repo) {
if (!repo) {
cb();
return;
}
new Input({
name: 'dest',
message: 'Destination directory?',
default: opts.dest || path.basename(repo)
})
.ask(function(dest) {
clone({repo: repo, dest: dest}, cb);
});
});
});
return prompt;
};