feat: read bool 更新

This commit is contained in:
2022-01-10 03:37:21 +08:00
parent 9137abdabf
commit 5826eef7bf
4 changed files with 29 additions and 5 deletions
+12
View File
@@ -5,6 +5,7 @@ import (
_ "embed"
"fmt"
"git.icechen.cn/pkg/wujian_develop_tool/config"
"github.com/sergi/go-diff/diffmatchpatch"
"os"
"github.com/fatih/color"
@@ -121,6 +122,17 @@ func copyTo(fileName string, toPath string) error {
return err
}
toFileContent, err := os.ReadFile(toPath)
if err == nil {
dmp := diffmatchpatch.New()
diffContent := dmp.DiffMain(string(fileContent), string(toFileContent), true)
diffString := dmp.DiffToDelta(diffContent)
if diffString == "" || util.ReadBoolWithMessage(diffString) {
color.Red("跳过文件: %s", fileName)
return nil
}
}
toFile, err := os.OpenFile(toPath, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, os.ModePerm)
if err != nil {
return err