Skip to content

Commit 65a7f48

Browse files
author
lihai2333
committed
git node版
1 parent 1b375d5 commit 65a7f48

File tree

7 files changed

+66
-0
lines changed

7 files changed

+66
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# fgit nodejs版
2+
3+
本工具由厉害制作,加速链接由[fastgit](https://hub.fastgit.org)提供。

bin/fgit.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#! /usr/bin/env node
2+
3+
var git = require("./../lib/git")
4+
var exec = require('child_process').exec;
5+
var argv = process.argv;
6+
var cloneRe = new RegExp("http[s]?://github.com/.*/.*|[email protected]:.*/.*", "i");
7+
8+
if (!argv[2]) {
9+
console.log("欢迎使用fgit。\n由厉害制作\n\n用 fgit clone [github仓库链接,只能是http或https的] 加速仓库克隆。");
10+
process.exit();
11+
}
12+
13+
if (argv[2] == "clone") {
14+
argv[2] == "clone" && cloneRe.test(argv[3])?exec("git clone " + argv[3].replace("github.com", "hub.fastgit.org"), function (err, stdout, srderr) {
15+
console.log("看来加速还是不错滴2333");
16+
}):(function () {
17+
console.log("第三个参数有问题哦");
18+
process.exit();})()
19+
} else {
20+
git(argv);
21+
}

lib/git.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
var exec = require('child_process').exec;
2+
3+
function send (data) {
4+
var Git;
5+
for (var i = 2;i < data.length;i++) {
6+
Git += data[i] + " ";
7+
}
8+
exec("git " + Git, function (err, stdout, srderr) {
9+
err?console.log(srderr.replace(/git/g, "fgit")):console.log(stdout);
10+
})
11+
}
12+
13+
function git (data) {
14+
/init|add|mv|restore|rm|sparse-checkout|bisect|biff|grep|log|show|status|branch|commit|merge|rebase|reset|switch|tag|fetch|pull|push/.test(data[2])?send (data):console.log("抱歉,没有这个命令");
15+
}
16+
17+
module.exports = git;

lib/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

package.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "fgit-cli",
3+
"version": "1.0.2",
4+
"main": "./lib/main.js",
5+
"bin": {
6+
"fgit": "bin/fgit.js"
7+
},
8+
"description": "加速github仓库克隆的速度",
9+
"directories": {
10+
"lib": "lib",
11+
"test": "test"
12+
},
13+
"author": "[email protected]",
14+
"license": "GPL3.0",
15+
"keywords": [
16+
"github",
17+
"加速",
18+
"clone",
19+
"克隆"
20+
],
21+
"scripts": {
22+
"test": "echo \"Error: no test specified\" && exit 1"
23+
}
24+
}

test/README.md

Whitespace-only changes.

test/package.json

Whitespace-only changes.

0 commit comments

Comments
 (0)