summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2021-10-19 09:19:02 +0700
committerShulhan <ms@kilabit.info>2021-10-19 09:19:02 +0700
commit6f0525a32ce7b0917e1498899799e640c5e4db4c (patch)
tree488002bf66acd58d8ab9ccb52479d992d87a3cc9
parentd0431d303c67cb98ef9f484b9df27852d3b762c3 (diff)
downloadgorankusu-6f0525a32ce7b0917e1498899799e640c5e4db4c.tar.xz
cmd/trunks: update the node when changes on .js and .html files
When the worker build received an update to .js or .html files, we run the Node.Update method on affected node to fetch their latest content. This is to allow the task to embed files, generate the latest content.
-rw-r--r--internal/cmd/trunks/main.go25
1 files changed, 19 insertions, 6 deletions
diff --git a/internal/cmd/trunks/main.go b/internal/cmd/trunks/main.go
index 1746209..c587752 100644
--- a/internal/cmd/trunks/main.go
+++ b/internal/cmd/trunks/main.go
@@ -126,11 +126,15 @@ func workerBuild(oneTime bool) {
`_www/tsconfig.json`,
},
Excludes: []string{
+ `.*\.adoc$`,
`.*\.d\.ts$`,
`.*\.git/.*`,
+ `/wui/.*/example.js$`,
+ `/wui/.*/index.html$`,
+ `/wui/index\.html$`,
+ `/wui\.bak`,
+ `/wui\.local`,
`docs`,
- `wui\.bak`,
- `wui\.local`,
},
},
Callback: func(ns *io.NodeState) {
@@ -155,16 +159,25 @@ func workerBuild(oneTime bool) {
} else if strings.HasSuffix(ns.Node.SysPath, ".json") {
mlog.Outf("%s: update %s\n", logp, ns.Node.SysPath)
tsCount++
- } else if strings.HasSuffix(ns.Node.SysPath, ".js") {
+ } else if strings.HasSuffix(ns.Node.SysPath, ".js") ||
+ strings.HasSuffix(ns.Node.SysPath, ".html") {
embedCount++
- mlog.Outf("%s: update %s\n", logp, ns.Node.SysPath)
- err = ns.Node.Update(nil, 0)
+ mlog.Outf("%s: update %s\n", logp, ns.Node.Path)
+ node, err := mfsWww.Get(ns.Node.Path)
if err != nil {
- mlog.Errf("%s: %s", logp, err)
+ mlog.Errf("%s: %q: %s", logp, ns.Node.Path, err)
+ continue
+ }
+ if node != nil {
+ err = node.Update(nil, 0)
+ if err != nil {
+ mlog.Errf("%s: %q: %s", logp, node.Path, err)
+ }
}
} else {
mlog.Outf("%s: unknown file updated %s\n", logp, ns.Node.SysPath)
}
+
case <-ticker.C:
if tsCount > 0 {
tsCount = 0