diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9825be4..3b79f4f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,3 +26,12 @@ jobs: - name: Test run: go test -v ./... + + - name: Vet + run: go vet -v ./... + + - name: install staticcheck + run: go install "honnef.co/go/tools/cmd/staticcheck@latest" + + - name: staticcheck + run: staticcheck ./... diff --git a/commands/init.go b/commands/init.go index d5d5b5b..c01eb1e 100644 --- a/commands/init.go +++ b/commands/init.go @@ -59,6 +59,9 @@ func (cmd *Init) Run(ctx *kong.Context) error { initfilesRoot := "initfiles" return fs.WalkDir(initfiles, initfilesRoot, func(path string, entry fs.DirEntry, err error) error { + if err != nil { + return err + } if path == initfilesRoot { return nil } diff --git a/commands/serve.go b/commands/serve.go index 52ec2ea..b39f893 100644 --- a/commands/serve.go +++ b/commands/serve.go @@ -135,18 +135,17 @@ func setupWatcher(config *config.Config) (*fsnotify.Watcher, *EventBroker, error // Add the layouts and all source directories to the given watcher func addAll(watcher *fsnotify.Watcher, config *config.Config) error { - err := watcher.Add(config.LayoutsDir) - err = watcher.Add(config.DataDir) - err = watcher.Add(config.IncludesDir) + watcher.Add(config.LayoutsDir) + watcher.Add(config.DataDir) + watcher.Add(config.IncludesDir) // fsnotify watches all files within a dir, but non recursively // this walks through the src dir and adds watches for each found directory - filepath.WalkDir(config.SrcDir, func(path string, entry fs.DirEntry, err error) error { + return filepath.WalkDir(config.SrcDir, func(path string, entry fs.DirEntry, err error) error { if entry.IsDir() { watcher.Add(path) } return nil }) - return err } func rebuildSite(config *config.Config, watcher *fsnotify.Watcher, broker *EventBroker) { diff --git a/go.mod b/go.mod index af44ff0..3c4ad71 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/facundoolano/jorge -go 1.22.0 +go 1.22 require ( github.com/alecthomas/chroma/v2 v2.5.0 @@ -12,8 +12,8 @@ require ( github.com/tdewolff/minify/v2 v2.20.16 github.com/yuin/goldmark v1.7.0 github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc - golang.org/x/net v0.0.0-20201224014010-6772e930b67b - golang.org/x/text v0.3.3 + golang.org/x/net v0.14.0 + golang.org/x/text v0.12.0 gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b ) diff --git a/go.sum b/go.sum index 85f6009..eab21d8 100644 --- a/go.sum +++ b/go.sum @@ -44,15 +44,12 @@ github.com/yuin/goldmark v1.7.0 h1:EfOIvIMZIzHdB/R/zVrikYLPPwJlfMcNczJFMs1m6sA= github.com/yuin/goldmark v1.7.0/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc h1:+IAOyRda+RLrxa1WC7umKOZRsGq4QrFFMYApOeHzQwQ= github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc/go.mod h1:ovIvrum6DQJA4QsJSovrkC4saKHQVs7TvcaeO8AIl5I= -golang.org/x/net v0.0.0-20201224014010-6772e930b67b h1:iFwSg7t5GZmB/Q5TjiEAsdoLDrdJRC1RiF2WhuV29Qw= -golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= +golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= diff --git a/main.go b/main.go index b9e723d..b396ec0 100644 --- a/main.go +++ b/main.go @@ -8,7 +8,7 @@ import ( var cli struct { Init commands.Init `cmd:"" help:"Initialize a new website project." aliases:"i"` Build commands.Build `cmd:"" help:"Build a website project." aliases:"b"` - Post commands.Post `cmd:"" help:"Initialize a new post template file." help:"title of the new post." aliases:"p"` + Post commands.Post `cmd:"" help:"Initialize a new post template file." aliases:"p"` Serve commands.Serve `cmd:"" help:"Run a local server for the website." aliases:"s"` Version kong.VersionFlag `short:"v"` } diff --git a/markup/smartify.go b/markup/smartify.go index 0302af6..74ff417 100644 --- a/markup/smartify.go +++ b/markup/smartify.go @@ -58,7 +58,6 @@ var smartifyTransforms = []struct { } var smartifyReplacer *strings.Replacer -var smartifyReplaceSpans = map[string]string{} func init() { smartifyReplacer = strings.NewReplacer( diff --git a/markup/smartify_test.go b/markup/smartify_test.go index 47c38ee..257c9e0 100644 --- a/markup/smartify_test.go +++ b/markup/smartify_test.go @@ -20,10 +20,11 @@ const string = "joe's garage"; ` output, err := Smartify(".html", strings.NewReader(input)) + assertEqual(t, err, nil) buf := new(strings.Builder) _, err = io.Copy(buf, output) - assertEqual(t, err, nil) + assertEqual(t, buf.String(), `