Add some features

This commit is contained in:
2023-09-13 11:45:24 +02:00
parent 760decfb85
commit 9e7f716be8
7 changed files with 485 additions and 48 deletions

View File

@@ -63,9 +63,8 @@ func link(from, to string) chan struct{} {
dest := filepath.Join(to, "node_modules", k)
fmt.Printf("Copying %s to %s\n", src, dest)
err := copy.Copy(src, dest, copy.Options{
Skip: func(src string) (bool, error) {
ok, _ := filepath.Match("*.js", filepath.Base(src))
if ok && !strings.Contains(src, "node_modules") {
Skip: func(stat fs.FileInfo, src, dest string) (bool, error) {
if !isExcludedPath(src, "node_modules", ".git") && (stat.IsDir() || isIncludedExt(filepath.Base(src), "*.js", "*.ts")) {
return false, nil
}
@@ -99,6 +98,25 @@ func link(from, to string) chan struct{} {
return requestBuildCh
}
func isExcludedPath(srcPath string, exPaths ...string) bool {
for _, exP := range exPaths {
if strings.Contains(srcPath, exP) {
return true
}
}
return false
}
func isIncludedExt(srcPath string, extensions ...string) bool {
for _, ext := range extensions {
if ok, _ := filepath.Match(ext, srcPath); ok {
return true
}
}
return false
}
func findFiles(root, name string) []string {
paths := []string{}