检查远程文件夹
(sshRemote common.SSHRemote, projectDirPath string, cmd *cobra.Command)
| 210 | |
| 211 | // 检查远程文件夹 |
| 212 | func checkRemoteDir(sshRemote common.SSHRemote, projectDirPath string, cmd *cobra.Command) error { |
| 213 | // 检测指定的文件夹是否有.ide.yaml,有了返回 |
| 214 | ideFilePath := common.FilePahtJoin4Linux(projectDirPath, ".ide/.ide.yaml") |
| 215 | hasIdeConfigYaml := sshRemote.IsFileExist(ideFilePath) |
| 216 | if hasIdeConfigYaml { |
| 217 | common.SmartIDELog.Info("当前目录已经完成初始化,无须再次进行!") |
| 218 | } |
| 219 | |
| 220 | // |
| 221 | if !sshRemote.IsDirExist(projectDirPath) { // 目录如果不存在就创建 |
| 222 | sshRemote.CheckAndCreateDir(projectDirPath) |
| 223 | } else { |
| 224 | // 检测并阻断 |
| 225 | isEmpty := sshRemote.IsDirEmpty(projectDirPath) // 检测当前文件夹是否为空 |
| 226 | if !isEmpty { |
| 227 | isContinue, _ := cmd.Flags().GetBool("yes") |
| 228 | if !isContinue { // 如果没有设置yes,那么就要给出提示 |
| 229 | var s string |
| 230 | common.SmartIDELog.Importance(i18nInstance.New.Info_noempty_is_comfirm) |
| 231 | fmt.Scanln(&s) |
| 232 | if s != "y" { |
| 233 | return errors.New("user exit") |
| 234 | } |
| 235 | } else { |
| 236 | common.SmartIDELog.Importance("当前文件夹不为空,当前文件夹内数据将被重置。") |
| 237 | sshRemote.Clear(projectDirPath) |
| 238 | } |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | return nil |
| 243 | } |
no test coverage detected