New version

This commit is contained in:
2024-11-06 10:43:05 +01:00
parent 79afdd39b8
commit 48b15de4c5
18 changed files with 1006 additions and 70 deletions

View File

@ -11,6 +11,7 @@ import (
"github.com/otiai10/copy"
"github.com/radovskyb/watcher"
"github.com/tidwall/gjson"
"github.com/trading-peter/gowebbuild/fsutils"
)
func link(from, to string) chan struct{} {
@ -25,7 +26,7 @@ func link(from, to string) chan struct{} {
}
packages := map[string]string{}
packageFiles := findFiles(from, "package.json")
packageFiles := fsutils.FindFiles(from, "package.json")
for i := range packageFiles {
content := readFileContent(packageFiles[i])
@ -118,24 +119,6 @@ func isIncludedExt(srcPath string, extensions ...string) bool {
return false
}
func findFiles(root, name string) []string {
paths := []string{}
filepath.WalkDir(root, func(path string, d fs.DirEntry, err error) error {
if err != nil {
return nil
}
if !d.IsDir() && filepath.Base(path) == name && !strings.Contains(path, "node_modules") {
paths = append(paths, path)
}
return nil
})
return paths
}
func readFileContent(path string) string {
pkgData, err := os.ReadFile(path)