Skip to content

Commit

Permalink
std-docs: use open for macOS.
Browse files Browse the repository at this point in the history
  • Loading branch information
jiacai2050 committed May 21, 2024
1 parent eb0f871 commit 6635360
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/compiler/std-docs.zig
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,19 @@ const Context = struct {
};

fn serveRequest(request: *std.http.Server.Request, context: *Context) !void {
if (std.mem.eql(u8, request.head.target, "/") or
std.mem.eql(u8, request.head.target, "/debug/"))
{
const target = std.mem.trimRight(u8, request.head.target, "/");
if (target.len == 0 or std.mem.eql(u8, target, "/debug")) {
try serveDocsFile(request, context, "docs/index.html", "text/html");
} else if (std.mem.eql(u8, request.head.target, "/main.js") or
std.mem.eql(u8, request.head.target, "/debug/main.js"))
} else if (std.mem.eql(u8, target, "/main.js") or
std.mem.eql(u8, target, "/debug/main.js"))
{
try serveDocsFile(request, context, "docs/main.js", "application/javascript");
} else if (std.mem.eql(u8, request.head.target, "/main.wasm")) {
} else if (std.mem.eql(u8, target, "/main.wasm")) {
try serveWasm(request, context, .ReleaseFast);
} else if (std.mem.eql(u8, request.head.target, "/debug/main.wasm")) {
} else if (std.mem.eql(u8, target, "/debug/main.wasm")) {
try serveWasm(request, context, .Debug);
} else if (std.mem.eql(u8, request.head.target, "/sources.tar") or
std.mem.eql(u8, request.head.target, "/debug/sources.tar"))
} else if (std.mem.eql(u8, target, "/sources.tar") or
std.mem.eql(u8, target, "/debug/sources.tar"))
{
try serveSourcesTar(request, context);
} else {
Expand Down Expand Up @@ -433,6 +432,7 @@ fn openBrowserTab(gpa: Allocator, url: []const u8) !void {
fn openBrowserTabThread(gpa: Allocator, url: []const u8) !void {
const main_exe = switch (builtin.os.tag) {
.windows => "explorer",
.macos => "open",
else => "xdg-open",
};
var child = std.ChildProcess.init(&.{ main_exe, url }, gpa);
Expand Down

0 comments on commit 6635360

Please sign in to comment.