检查远程文件夹
(sshRemote common.SSHRemote, projectDirPath string, cmd *cobra.Command)
| 126 | |
| 127 | // 检查远程文件夹 |
| 128 | func checkRemoteDir(sshRemote common.SSHRemote, projectDirPath string, cmd *cobra.Command) error { |
| 129 | // 检测指定的文件夹是否有.ide.yaml,有了返回 |
| 130 | ideFilePath := common.FilePahtJoin4Linux(projectDirPath, ".ide/.ide.yaml") |
| 131 | hasIdeConfigYaml := sshRemote.IsFileExist(ideFilePath) |
| 132 | if hasIdeConfigYaml { |
| 133 | common.SmartIDELog.Info("当前目录已经完成初始化,无须再次进行!") |
| 134 | } |
| 135 | |
| 136 | // |
| 137 | if !sshRemote.IsDirExist(projectDirPath) { // 目录如果不存在就创建 |
| 138 | sshRemote.CheckAndCreateDir(projectDirPath) |
| 139 | } else { |
| 140 | // 检测并阻断 |
| 141 | isEmpty := sshRemote.IsDirEmpty(projectDirPath) // 检测当前文件夹是否为空 |
| 142 | if !isEmpty { |
| 143 | isContinue, _ := cmd.Flags().GetBool("yes") |
| 144 | if !isContinue { // 如果没有设置yes,那么就要给出提示 |
| 145 | var s string |
| 146 | common.SmartIDELog.Importance(i18nInstance.New.Info_noempty_is_comfirm) |
| 147 | fmt.Scanln(&s) |
| 148 | if s != "y" { |
| 149 | return errors.New("user exit") |
| 150 | } |
| 151 | } else { |
| 152 | common.SmartIDELog.Importance("当前文件夹不为空,当前文件夹内数据将被重置。") |
| 153 | sshRemote.Clear(projectDirPath) |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | return nil |
| 159 | } |
no test coverage detected