Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std-docs: use open for macOS. #19707

Merged
merged 3 commits into from
May 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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