From 6f0525a32ce7b0917e1498899799e640c5e4db4c Mon Sep 17 00:00:00 2001 From: Shulhan Date: Tue, 19 Oct 2021 09:19:02 +0700 Subject: 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. --- internal/cmd/trunks/main.go | 25 +++++++++++++++++++------ 1 file 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 -- cgit v1.3