* 构建 Git add 命令
(params: Record<string, any>)
| 91 | * 构建 Git add 命令 |
| 92 | */ |
| 93 | protected async buildCommand(params: Record<string, any>): Promise<string> { |
| 94 | const { files, all, update, dryRun } = params; |
| 95 | |
| 96 | let command = 'git add'; |
| 97 | |
| 98 | // 添加选项 |
| 99 | if (dryRun) { |
| 100 | command += ' --dry-run'; |
| 101 | } |
| 102 | |
| 103 | if (all) { |
| 104 | command += ' -A'; |
| 105 | } else if (update) { |
| 106 | command += ' -u'; |
| 107 | } else if (files) { |
| 108 | const fileList = files.split(/\s+/).filter((f: string) => f.trim()); |
| 109 | command += ` ${fileList.join(' ')}`; |
| 110 | } else { |
| 111 | // 默认添加当前目录下所有文件 |
| 112 | command += ' .'; |
| 113 | } |
| 114 | |
| 115 | return command; |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * 获取确认选项 |