zen-gitsync 1.2.4 → 1.2.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zen-gitsync",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "description": "控制台输入g,回车,输入提交内容,自动执行git add+commit+push",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/src/gitCommit.js CHANGED
@@ -82,7 +82,7 @@ class GitCommit {
82
82
  }
83
83
 
84
84
  // 执行 git add .
85
- this.statusOutput.includes('(use "git add <file>') && this.execSyncGitCommand('git add .')
85
+ this.statusOutput.includes('(use "git add') && this.execSyncGitCommand('git add .')
86
86
 
87
87
  // 执行 git commit
88
88
  if (this.statusOutput.includes('Untracked files:') || this.statusOutput.includes('Changes not staged for commit') || this.statusOutput.includes('Changes to be committed')) {
@@ -34,7 +34,8 @@ function getRandomColor() {
34
34
  function resetColor() {
35
35
  return '\x1b[0m';
36
36
  }
37
- const coloredLog = (...args) =>{
37
+
38
+ const coloredLog = (...args) => {
38
39
  const color = getRandomColor();
39
40
  // 获取控制台的宽度
40
41
  const terminalWidth = process.stdout.columns;
@@ -43,8 +44,8 @@ const coloredLog = (...args) =>{
43
44
  // const line = '-'.repeat(terminalWidth);
44
45
  let str = '├─'
45
46
  let str2 = '│'
46
- const start_line = '┌' + '──'.repeat(terminalWidth / 2 - 1) + '┐';
47
- const end_line = '└' + '──'.repeat(terminalWidth / 2 - 1) + '┘';
47
+ const start_line = '┌' + ''.repeat(terminalWidth - 2) + '┐';
48
+ const end_line = '└' + ''.repeat(terminalWidth - 2) + '┘';
48
49
  let _args = args.map(arg => arg.split('\n')).flat().filter(arg => arg.trim() !== '');
49
50
  console.log(start_line);
50
51
  _args.map(async (arg, i) => {
@@ -62,34 +63,45 @@ const coloredLog = (...args) =>{
62
63
  if (_args[0] === 'git status' && trim_arg.startsWith('modified:')) {
63
64
  _color = '\x1b[32m';
64
65
  }
66
+ if (_args[0] === 'git status' && trim_arg.startsWith('deleted:')) {
67
+ _color = '\x1b[31m';
68
+ }
65
69
  if (_args[0] === 'git diff' && arg.startsWith('@@ ')) {
66
70
  _color = '\x1b[36m';
67
71
  }
68
72
  // 测试边框
69
73
  let fix_end = ''
70
74
  let length = stringWidth(arg);
71
- if (length < terminalWidth) {
75
+ // if (length < terminalWidth) {
72
76
  let fix2 = 0
73
- if(trim_arg.startsWith('modified:')){
77
+ if (
78
+ _args[0] === 'git status' && trim_arg.startsWith('modified:')
79
+ || _args[0] === 'git status' && trim_arg.startsWith('deleted:')
80
+ ) {
74
81
  fix2 = 6
75
82
  }
76
83
  if (i === 0) {
77
84
  fix2 = 2
78
85
  }
79
- fix_end = ' '.repeat(terminalWidth - length - 4 - fix2)
86
+ let repeatLen = terminalWidth - length - 3 - fix2
87
+ if (repeatLen < 0) {
88
+ // repeatLen += terminalWidth
89
+ repeatLen = repeatLen % terminalWidth + terminalWidth
90
+ }
91
+ fix_end = ' '.repeat(repeatLen)
80
92
  fix_end += "│"
81
- }
93
+ // }
82
94
  // console.log(`fix_end ==> `, fix_end)
83
95
  if (i === 0) {
84
96
  console.log(`│ \x1b[1m\x1b[34m> ${arg}\x1b[22m\x1b[39m${fix_end}`);
85
- let mid = '├─' + '──'.repeat(terminalWidth / 2 - 2) + '─┤';
97
+ let mid = '' + ''.repeat(terminalWidth - 2) + '';
86
98
  console.log(mid);
87
99
  } else {
88
- if(arg.trim().length > 0) {
100
+ if (arg.trim().length > 0) {
89
101
  console.log(`│${_color} ${arg}${resetColor()}${fix_end}`);
90
102
  }
91
103
  }
92
104
  });
93
105
  console.log(end_line);
94
106
  }
95
- export { coloredLog };
107
+ export {coloredLog};