From f69d56187bc5330dac7b7ce1cced03f318e49f68 Mon Sep 17 00:00:00 2001 From: James Mills Date: Sat, 24 Aug 2024 16:17:22 +1000 Subject: [PATCH] Fix bugs with referencing non-existent layouts --- main.go | 8 ++++---- testdata/simple/.zs/layout.html | 4 +--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index d1ba02d..6cdc6b5 100644 --- a/main.go +++ b/main.go @@ -396,9 +396,9 @@ func getVars(path string, globals Vars) (Vars, string, error) { return nil, "", nil } - b, err := ioutil.ReadFile(path) + b, err := os.ReadFile(path) if err != nil { - return nil, "", err + return nil, "", fmt.Errorf("error getting vars from %q: %w", path, err) } s := string(b) @@ -608,7 +608,7 @@ func buildAll(ctx context.Context, watch bool) error { return ctx.Err() case <-ticker.C: os.Mkdir(PUBDIR, 0755) - filepath.Walk(".", func(path string, info os.FileInfo, err error) error { + err := filepath.Walk(".", func(path string, info os.FileInfo, err error) error { // 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 { @@ -658,7 +658,7 @@ func buildAll(ctx context.Context, watch bool) error { } } if !watch { - return nil + return err } lastModified = time.Now() } diff --git a/testdata/simple/.zs/layout.html b/testdata/simple/.zs/layout.html index 5744e79..cddd070 100644 --- a/testdata/simple/.zs/layout.html +++ b/testdata/simple/.zs/layout.html @@ -1,3 +1 @@ - - {{ content }} - +{{ content }}