Signed-off-by: Izuru Yakumo <yakumo.izuru@chaotic.ninja>

git-svn-id: file:///srv/svn/repo/aya/trunk@88 cec141ff-132a-4243-88a5-ce187bd62f94
This commit is contained in:
yakumo.izuru 2024-06-17 15:43:09 +00:00
parent efcb25e6e5
commit f0da6dc37f
2 changed files with 41 additions and 40 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
*~
*.bak
**.pub
*.sw*
/aya
/dist

View File

@ -12,46 +12,46 @@ import (
)
func buildAll(watch bool) {
lastModified := time.Unix(0, 0)
modified := false
lastModified := time.Unix(0, 0)
modified := false
vars := globals()
for {
os.Mkdir(PUBDIR, 0755)
filepath.Walk(".", func(path string, info os.FileInfo, err error) error {
// ignore hidden files and directories
if filepath.Base(path)[0] == '.' || strings.HasPrefix(path, ".") {
return nil
}
// inform user about fs walk errors, but continue iteration
if err != nil {
fmt.Println("error:", err)
return nil
}
vars := globals()
for {
os.Mkdir(PUBDIR, 0755)
filepath.Walk(".", func(path string, info os.FileInfo, err error) error {
// ignore hidden files and directories
if filepath.Base(path)[0] == '.' || strings.HasPrefix(path, ".") {
return nil
}
// inform user about fs walk errors, but continue iteration
if err != nil {
fmt.Println("error:", err)
return nil
}
if info.IsDir() {
os.Mkdir(filepath.Join(PUBDIR, path), 0755)
return nil
} else if info.ModTime().After(lastModified) {
if !modified {
// First file in this build cycle is about to be modified
run(vars, "prehook")
modified = true
}
fmt.Println("GEN", path)
return build(path, nil, vars)
}
return nil
})
if modified {
// At least one file in this build cycle has been modified
run(vars, "posthook")
modified = false
}
if !watch {
break
}
lastModified = time.Now()
time.Sleep(1 * time.Second)
}
if info.IsDir() {
os.Mkdir(filepath.Join(PUBDIR, path), 0755)
return nil
} else if info.ModTime().After(lastModified) {
if !modified {
// First file in this build cycle is about to be modified
run(vars, "prehook")
modified = true
}
fmt.Println("GEN", path)
return build(path, nil, vars)
}
return nil
})
if modified {
// At least one file in this build cycle has been modified
run(vars, "posthook")
modified = false
}
if !watch {
break
}
lastModified = time.Now()
time.Sleep(1 * time.Second)
}
}