From 304c2cba42abf9a4d1a603c57976f21799624ab1 Mon Sep 17 00:00:00 2001 From: Bob Farrell Date: Thu, 14 Mar 2024 20:29:35 +0000 Subject: [PATCH] Fix Windows "jetzig server" command --- cli/commands/server.zig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cli/commands/server.zig b/cli/commands/server.zig index 8395c3d..2e01e43 100644 --- a/cli/commands/server.zig +++ b/cli/commands/server.zig @@ -1,6 +1,7 @@ const std = @import("std"); const args = @import("args"); const util = @import("../util.zig"); +const builtin = @import("builtin"); pub const watch_changes_pause_duration = 1 * 1000 * 1000 * 1000; @@ -148,6 +149,9 @@ fn locateExecutable(allocator: std.mem.Allocator, dir: std.fs.Dir) !?[]const u8 defer allocator.free(content); const exe_name = util.strip(content); + const suffix = if (builtin.os.tag == .windows) ".exe" else ""; + const full_name = try std.mem.concat(allocator, u8, &[_][]const u8{ exe_name, suffix }); + defer allocator.free(full_name); // XXX: Will fail if user sets a custom install path. var bin_dir = try dir.openDir("zig-out/bin", .{ .iterate = true }); @@ -157,7 +161,7 @@ fn locateExecutable(allocator: std.mem.Allocator, dir: std.fs.Dir) !?[]const u8 defer walker.deinit(); while (try walker.next()) |entry| { - if (entry.kind == .file and std.mem.eql(u8, entry.path, exe_name)) { + if (entry.kind == .file and std.mem.eql(u8, entry.path, full_name)) { return try bin_dir.realpathAlloc(allocator, entry.path); } }