diff options
| author | Xe Iaso <me@xeiaso.net> | 2023-11-03 12:53:29 -0400 |
|---|---|---|
| committer | Xe Iaso <me@xeiaso.net> | 2023-11-03 12:54:28 -0400 |
| commit | e82f05d9ed6c66479ddd29d399618d9fc72882e4 (patch) | |
| tree | e39e2f0a1db6048a41043719765aa50b84bc4482 | |
| parent | edbc8f1e5ca218092bb60b6f5febee20f8148ec9 (diff) | |
| download | xesite-e82f05d9ed6c66479ddd29d399618d9fc72882e4.tar.xz xesite-e82f05d9ed6c66479ddd29d399618d9fc72882e4.zip | |
cmd/xesite: debounce rebuild events
Signed-off-by: Xe Iaso <me@xeiaso.net>
| -rw-r--r-- | cmd/xesite/devel.go | 16 | ||||
| -rw-r--r-- | flake.lock | 40 | ||||
| -rw-r--r-- | go.mod | 1 | ||||
| -rw-r--r-- | go.sum | 2 | ||||
| -rw-r--r-- | gomod2nix.toml | 3 |
5 files changed, 47 insertions, 15 deletions
diff --git a/cmd/xesite/devel.go b/cmd/xesite/devel.go index 944af30..23f35ff 100644 --- a/cmd/xesite/devel.go +++ b/cmd/xesite/devel.go @@ -7,7 +7,9 @@ import ( "os" "path/filepath" "strings" + "time" + "github.com/bep/debounce" "gopkg.in/fsnotify.v1" "xeiaso.net/v4/internal/lume" ) @@ -55,6 +57,15 @@ func rebuildOnChange(fs *lume.FS) { } defer watcher.Close() + reload := func() { + slog.Info("reloading") + if err := fs.Update(context.Background()); err != nil { + slog.Error("reload failed", "err", err) + } + } + + d := debounce.New(100 * time.Millisecond) + if err = watcher.Add("./lume"); err != nil { log.Fatal(err) } @@ -84,10 +95,7 @@ func rebuildOnChange(fs *lume.FS) { slog.Debug("got event", "fname", event.Name, "op", event.Op.String()) - slog.Info("reloading") - if err := fs.Update(context.Background()); err != nil { - slog.Error("reload failed", "err", err) - } + d(reload) case err := <-watcher.Errors: log.Fatal(err) } @@ -163,7 +163,7 @@ }, "flake-utils_2": { "inputs": { - "systems": "systems_2" + "systems": "systems_3" }, "locked": { "lastModified": 1692799911, @@ -181,7 +181,7 @@ }, "flake-utils_3": { "inputs": { - "systems": "systems_3" + "systems": "systems_4" }, "locked": { "lastModified": 1692799911, @@ -226,11 +226,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1679684486, - "narHash": "sha256-XMpeeKmzxYpkh8uuxyGHcYzgORVysC8vMIVbzQdPtTs=", + "lastModified": 1698939764, + "narHash": "sha256-CH68pMKscwAxi/N5xbRlZ5i2NNzMZx6fjzcQkPN3bSw=", "owner": "Xe", "repo": "iosevka", - "rev": "85a6850cf67884b2d4752442bb9246415681e9e9", + "rev": "faa4a6ed96820a85790244f9b65c4b0f4604ae2d", "type": "github" }, "original": { @@ -241,11 +241,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1678898370, - "narHash": "sha256-xTICr1j+uat5hk9FyuPOFGxpWHdJRibwZC+ATi0RbtE=", + "lastModified": 1698611440, + "narHash": "sha256-jPjHjrerhYDy3q9+s5EAsuhyhuknNfowY6yt6pjn9pc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "ac718d02867a84b42522a0ece52d841188208f2c", + "rev": "0cbe9f69c234a7700596e943bfae7ef27a31b735", "type": "github" }, "original": { @@ -352,6 +352,21 @@ "type": "github" } }, + "systems_4": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "typst": { "inputs": { "crane": "crane", @@ -376,12 +391,15 @@ } }, "utils": { + "inputs": { + "systems": "systems_2" + }, "locked": { - "lastModified": 1678901627, - "narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=", + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", "owner": "numtide", "repo": "flake-utils", - "rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", "type": "github" }, "original": { @@ -35,6 +35,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/sts v1.18.10 // indirect github.com/aws/smithy-go v1.13.5 // indirect github.com/beorn7/perks v1.0.1 // indirect + github.com/bep/debounce v1.2.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cloudflare/circl v1.3.3 // indirect github.com/coreos/go-iptables v0.6.0 // indirect @@ -49,6 +49,8 @@ github.com/aws/smithy-go v1.13.5 h1:hgz0X/DX0dGqTYpGALqXJoRKRj5oQ7150i5FdTePzO8= github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bep/debounce v1.2.1 h1:v67fRdBA9UQu2NhLFXrSg0Brw7CexQekrBwDMM8bzeY= +github.com/bep/debounce v1.2.1/go.mod h1:H8yggRPQKLUhUoqrJC1bO2xNya7vanpDl7xR3ISbCJ0= github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= diff --git a/gomod2nix.toml b/gomod2nix.toml index 6109d42..ef6caed 100644 --- a/gomod2nix.toml +++ b/gomod2nix.toml @@ -64,6 +64,9 @@ schema = 3 [mod."github.com/beorn7/perks"] version = "v1.0.1" hash = "sha256-h75GUqfwJKngCJQVE5Ao5wnO3cfKD9lSIteoLp/3xJ4=" + [mod."github.com/bep/debounce"] + version = "v1.2.1" + hash = "sha256-7qHOp4vB0ifEseXXBuSH6W5YNImVcb8PTWSJJAMaGcU=" [mod."github.com/cespare/xxhash/v2"] version = "v2.2.0" hash = "sha256-nPufwYQfTkyrEkbBrpqM3C2vnMxfIz6tAaBmiUP7vd4=" |
