aboutsummaryrefslogtreecommitdiff
path: root/ciigo.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2021-10-10 21:31:00 +0700
committerShulhan <ms@kilabit.info>2021-10-10 21:31:00 +0700
commit06d03f6afe37124c486a34c120fcb05a8ae86d5e (patch)
tree98be3734ef6613b42878829bda7a19eed2e59576 /ciigo.go
parent88504a35592cf0c1a714d0a7454cdf95c7adec8b (diff)
downloadciigo-06d03f6afe37124c486a34c120fcb05a8ae86d5e.tar.xz
all: check markup modification time before converting to HTML
Previously, when the Convert, Watch or Serve running it will convert all markup files into HTML without checking if the adoc has been modified or newer than HTML file. This changes check the modification time of markup file first before converting them, to minimize unnecessary operation.
Diffstat (limited to 'ciigo.go')
-rw-r--r--ciigo.go27
1 files changed, 11 insertions, 16 deletions
diff --git a/ciigo.go b/ciigo.go
index c551ddd..a5d4e84 100644
--- a/ciigo.go
+++ b/ciigo.go
@@ -241,12 +241,16 @@ func listFileMarkups(dir string, excRE []*regexp.Regexp) (
for _, fi := range fis {
name := fi.Name()
+ filePath := filepath.Join(dir, name)
- if fi.IsDir() && name[0] != '.' {
- newdir := filepath.Join(dir, fi.Name())
- fmarkups, err := listFileMarkups(newdir, excRE)
+ if fi.IsDir() {
+ if name[0] == '.' {
+ // Skip any directory start with '.'.
+ continue
+ }
+ fmarkups, err := listFileMarkups(filePath, excRE)
if err != nil {
- return nil, fmt.Errorf("%s: %w", logp, err)
+ return nil, fmt.Errorf("%s: %s: %w", logp, filePath, err)
}
for k, v := range fmarkups {
fileMarkups[k] = v
@@ -261,22 +265,13 @@ func listFileMarkups(dir string, excRE []*regexp.Regexp) (
if fi.Size() == 0 {
continue
}
-
- filePath := filepath.Join(dir, name)
-
if isExcluded(filePath, excRE) {
continue
}
-
- fmarkup := &fileMarkup{
- path: filePath,
- info: fi,
- basePath: strings.TrimSuffix(filePath, ext),
- fhtml: &fileHTML{},
+ fmarkup, err := newFileMarkup(filePath, fi)
+ if err != nil {
+ return nil, fmt.Errorf("%s: %s: %w", logp, filePath, err)
}
-
- fmarkup.fhtml.path = fmarkup.basePath + ".html"
-
fileMarkups[filePath] = fmarkup
}