-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
executable file
·45 lines (35 loc) · 851 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
45
#!/usr/bin/env node
const clipboardy = require('clipboardy');
const spawn = require("child_process").spawn,
shell = require("shelljs");
const url = process.argv[2];
if(!url){
console.log("fatal: You must specify a repository to clone.");
process.exit(1);
}
if (url.includes('@')){
// Lets say its ssh
var path = url
.split("@")
.slice(1)
.join('/')
.replace(':', '/')
.replace(".git", "");
} else {
// Assume its http
var path = url
.split("/")
.slice(2)
.join("/")
.replace(".git", "");
}
if (process.argv[3]) {
var parentDirectories = process.argv[3];
if (parentDirectories.substr(-1) !== "/") {
parentDirectories = parentDirectories + "/";
}
path = parentDirectories + path;
}
clipboardy.writeSync(path);
shell.mkdir("-p", path);
spawn("git", ["clone", url, path], { stdio: "inherit" });