Fix tests

This commit is contained in:
James Mills 2023-03-18 17:40:46 +10:00
parent 3e4215b694
commit 5b82d79c90
No known key found for this signature in database
GPG Key ID: AC4C014F1440EBD6
5 changed files with 11 additions and 6 deletions

View File

@ -4,6 +4,7 @@ package main
import ( import (
"bytes" "bytes"
"context" "context"
"errors"
"fmt" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
@ -520,7 +521,9 @@ func buildAll(ctx context.Context, watch bool) error {
filepath.Walk(".", func(path string, info os.FileInfo, err error) error { filepath.Walk(".", func(path string, info os.FileInfo, err error) error {
// rebuild if changes to .zs/ or .zsignore // rebuild if changes to .zs/ or .zsignore
if (filepath.Base(path) == ZSIGNORE || filepath.Dir(path) == ZSDIR) && info.ModTime().After(lastModified) { if (filepath.Base(path) == ZSIGNORE || filepath.Dir(path) == ZSDIR) && info.ModTime().After(lastModified) {
Ignore = ParseIgnoreFile(path) if filepath.Base(path) == ZSIGNORE {
Ignore = ParseIgnoreFile(path)
}
// reset lastModified to 0 so everything rebuidls // reset lastModified to 0 so everything rebuidls
lastModified = time.Unix(0, 0) lastModified = time.Unix(0, 0)
return nil return nil
@ -623,7 +626,9 @@ func init() {
func ParseIgnoreFile(fn string) *ignore.GitIgnore { func ParseIgnoreFile(fn string) *ignore.GitIgnore {
obj, err := ignore.CompileIgnoreFile(ZSIGNORE) obj, err := ignore.CompileIgnoreFile(ZSIGNORE)
if err != nil { if err != nil {
log.WithError(err).Warnf("error parsing .zsignore: %s (using defaults)s", fn) if !errors.Is(err, os.ErrNotExist) {
log.WithError(err).Warnf("error parsing .zsignore: %s (using defaults)s", fn)
}
return ignore.CompileIgnoreLines(DefaultIgnore) return ignore.CompileIgnoreLines(DefaultIgnore)
} }

View File

@ -2,7 +2,7 @@
<head> <head>
<title>Hello World</title> <title>Hello World</title>
</head> </head>
<body><h1 id="hello-world">Hello World</h1> <body><h1 id="hello-world">Hello World <a class="anchor" href="#hello-world"></a></h1>
<p>Hello World!</p> <p>Hello World!</p>
</body> </body>
</html> </html>

View File

@ -1,5 +1,5 @@
<html> <html>
<body><h1 id="simple">Simple</h1> <body><h1 id="simple">Simple <a class="anchor" href="#simple"></a></h1>
<p>Simple page</p> <p>Simple page</p>
</body> </body>
</html> </html>

View File

@ -1,5 +1,5 @@
<html> <html>
<body><h1 id="simple">Simple</h1> <body><h1 id="simple">Simple <a class="anchor" href="#simple"></a></h1>
<p>Simple page</p> <p>Simple page</p>
</body> </body>
</html> </html>

View File

@ -2,7 +2,7 @@
<head> <head>
<title>Simple</title> <title>Simple</title>
</head> </head>
<body><h1 id="simple">Simple</h1> <body><h1 id="simple">Simple <a class="anchor" href="#simple"></a></h1>
<p>Simple page</p> <p>Simple page</p>
</body> </body>
</html> </html>