From 8ad17f51894304ed87821c5c8284e3ad494ed836 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Sat, 7 Mar 2026 20:32:13 +0100 Subject: [PATCH] fix: make sure paths are absolute before watching them --- src/nightwatch.zig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/nightwatch.zig b/src/nightwatch.zig index cf753a9..31550c8 100644 --- a/src/nightwatch.zig +++ b/src/nightwatch.zig @@ -75,9 +75,11 @@ pub fn deinit(self: *@This()) void { /// all subdirectories are watched recursively and new directories created /// inside are watched automatically. pub fn watch(self: *@This(), path: []const u8) Error!void { - try self.interceptor.backend.add_watch(self.allocator, path); + var buf: [std.fs.max_path_bytes]u8 = undefined; + const abs_path = std.fs.cwd().realpath(path, &buf) catch return error.WatchFailed; + try self.interceptor.backend.add_watch(self.allocator, abs_path); if (!Backend.watches_recursively) { - recurse_watch(&self.interceptor.backend, self.allocator, path); + recurse_watch(&self.interceptor.backend, self.allocator, abs_path); } }