zen-gitsync 1.2.3 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -3
- package/package.json +3 -2
- package/src/gitCommit.js +14 -4
package/README.md
CHANGED
|
@@ -26,17 +26,25 @@ npm install -g zen-gitsync
|
|
|
26
26
|
- `git push`
|
|
27
27
|
|
|
28
28
|
### 示例:
|
|
29
|
-
|
|
29
|
+
#### 交互式提交:
|
|
30
30
|
```bash
|
|
31
31
|
$ g
|
|
32
32
|
请输入你的提交信息: 修复了登录页样式问题
|
|
33
33
|
```
|
|
34
|
-
|
|
34
|
+
#### 直接提交:
|
|
35
35
|
```bash
|
|
36
36
|
$ g -y
|
|
37
37
|
```
|
|
38
|
-
定时执行自动提交,默认间隔1小时
|
|
38
|
+
#### 定时执行自动提交,默认间隔1小时
|
|
39
39
|
```bash
|
|
40
40
|
$ g -y --interval
|
|
41
41
|
$ g -y --interval=秒数
|
|
42
42
|
```
|
|
43
|
+
#### 指定目录提交
|
|
44
|
+
```bash
|
|
45
|
+
$ g --path=./
|
|
46
|
+
```
|
|
47
|
+
或
|
|
48
|
+
```bash
|
|
49
|
+
$ g --cwd=./
|
|
50
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zen-gitsync",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "控制台输入g,回车,输入提交内容,自动执行git add+commit+push",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"g": "node ./src/gitCommit.js",
|
|
9
9
|
"g:y": "node ./src/gitCommit.js -y",
|
|
10
10
|
"g:y:interval": "node ./src/gitCommit.js -y --interval",
|
|
11
|
-
"g:y:interval10": "node ./src/gitCommit.js -y --interval=10"
|
|
11
|
+
"g:y:interval10": "node ./src/gitCommit.js -y --interval=10",
|
|
12
|
+
"g:cwd": "node ./src/gitCommit.js --path=./"
|
|
12
13
|
},
|
|
13
14
|
"files": [
|
|
14
15
|
"src/gitCommit.js",
|
package/src/gitCommit.js
CHANGED
|
@@ -18,6 +18,16 @@ const judgePlatform = () => {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
|
+
const getCwd = () => {
|
|
22
|
+
const cwdArg = process.argv.find(arg => arg.startsWith('--path')) || process.argv.find(arg => arg.startsWith('--cwd'));
|
|
23
|
+
if (cwdArg) {
|
|
24
|
+
// console.log(`cwdArg ==> `, cwdArg)
|
|
25
|
+
const [, value] = cwdArg.split('=')
|
|
26
|
+
// console.log(`value ==> `, value)
|
|
27
|
+
return value || process.cwd()
|
|
28
|
+
}
|
|
29
|
+
return process.cwd()
|
|
30
|
+
}
|
|
21
31
|
|
|
22
32
|
// 有时候有乱码呢123神奇
|
|
23
33
|
|
|
@@ -102,8 +112,8 @@ class GitCommit {
|
|
|
102
112
|
|
|
103
113
|
execSyncGitCommand(command, options = {}) {
|
|
104
114
|
try {
|
|
105
|
-
let {encoding = 'utf-8', maxBuffer = 30 * 1024 * 1024
|
|
106
|
-
|
|
115
|
+
let {encoding = 'utf-8', maxBuffer = 30 * 1024 * 1024} = options
|
|
116
|
+
let cwd = getCwd()
|
|
107
117
|
const output = execSync(command, {encoding, maxBuffer, cwd})
|
|
108
118
|
let result = output.trim()
|
|
109
119
|
coloredLog(command, result)
|
|
@@ -115,8 +125,8 @@ class GitCommit {
|
|
|
115
125
|
}
|
|
116
126
|
|
|
117
127
|
execGitCommand(command, options = {}, callback) {
|
|
118
|
-
let {encoding = 'utf-8', maxBuffer = 30 * 1024 * 1024
|
|
119
|
-
|
|
128
|
+
let {encoding = 'utf-8', maxBuffer = 30 * 1024 * 1024} = options
|
|
129
|
+
let cwd = getCwd()
|
|
120
130
|
exec(command, {encoding, maxBuffer, cwd}, (error, stdout, stderr) => {
|
|
121
131
|
if (error) {
|
|
122
132
|
coloredLog(command, error)
|