diff options
| author | Shulhan <ms@kilabit.info> | 2022-02-19 01:19:51 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2022-02-19 01:19:51 +0700 |
| commit | fdc557949e898f7284a080c75231a438f8f998b5 (patch) | |
| tree | 49fed4fde810cd0c39fa83103042e0f6fcff1525 | |
| parent | 41117b40ee781e56b160902f94e5d57b71ab621c (diff) | |
| download | ciigo-fdc557949e898f7284a080c75231a438f8f998b5.tar.xz | |
all: fix adoc files not re-converted when template file changes
In commit 06d03f6afe37 we skip converting files if the generated HTML
is newer than adoc file.
This cause an issue where the template file changes during Watch or
Serve, but the HTML files is not regenerated.
| -rw-r--r-- | ciigo.go | 4 | ||||
| -rw-r--r-- | htmlgenerator.go | 6 | ||||
| -rw-r--r-- | server.go | 2 | ||||
| -rw-r--r-- | watcher.go | 2 |
4 files changed, 8 insertions, 6 deletions
@@ -69,7 +69,7 @@ func Convert(opts *ConvertOptions) (err error) { return fmt.Errorf("%s: %w", logp, err) } - htmlg.convertFileMarkups(fileMarkups) + htmlg.convertFileMarkups(fileMarkups, false) return nil } @@ -112,7 +112,7 @@ func GoEmbed(opts *EmbedOptions) (err error) { return fmt.Errorf("%s: %w", logp, err) } - htmlg.convertFileMarkups(fileMarkups) + htmlg.convertFileMarkups(fileMarkups, false) memfsOpts := &memfs.Options{ Root: opts.Root, diff --git a/htmlgenerator.go b/htmlgenerator.go index e6b29fd..4819217 100644 --- a/htmlgenerator.go +++ b/htmlgenerator.go @@ -95,11 +95,13 @@ func (htmlg *htmlGenerator) convert(fmarkup *fileMarkup) (err error) { // // convertFileMarkups convert markup files into HTML. // -func (htmlg *htmlGenerator) convertFileMarkups(fileMarkups map[string]*fileMarkup) { +func (htmlg *htmlGenerator) convertFileMarkups(fileMarkups map[string]*fileMarkup, isForce bool) { logp := "convertFileMarkups" for _, fmarkup := range fileMarkups { if !fmarkup.isNewerThanHtml() { - continue + if !isForce { + continue + } } err := htmlg.convert(fmarkup) @@ -85,7 +85,7 @@ func newServer(opts *ServeOptions) (srv *server, err error) { return nil, fmt.Errorf("%s: %w", logp, err) } - srv.htmlg.convertFileMarkups(srv.watcher.fileMarkups) + srv.htmlg.convertFileMarkups(srv.watcher.fileMarkups, false) } return srv, nil @@ -171,7 +171,7 @@ func (w *watcher) onChangeHtmlTemplate(ns *libio.NodeState) { } fmt.Printf("%s: regenerate all markup files ...\n", logp) - w.htmlg.convertFileMarkups(w.fileMarkups) + w.htmlg.convertFileMarkups(w.fileMarkups, true) } // |
