| ... | @@ -56,14 +56,24 @@ pub fn execute(args: [][]u8) !void { | ... | @@ -56,14 +56,24 @@ pub fn execute(args: [][]u8) !void { |
| 56 | } | 56 | } |
| 57 | } | 57 | } |
| 58 | | 58 | |
| | 59 | const has_zigdotmod = blk: { |
| | 60 | const _url = try std.mem.join(gpa, "/", &.{ found.git, "blob", "HEAD", "zig.mod" }); |
| | 61 | const _req = try zfetch.Request.init(gpa, _url, null); |
| | 62 | defer _req.deinit(); |
| | 63 | try _req.do(.GET, null, null); |
| | 64 | break :blk _req.status.code == 200; |
| | 65 | }; |
| | 66 | |
| 59 | const file = try std.fs.cwd().openFile("zig.mod", .{ .read = true, .write = true }); | 67 | const file = try std.fs.cwd().openFile("zig.mod", .{ .read = true, .write = true }); |
| 60 | try file.seekTo(try file.getEndPos()); | 68 | try file.seekTo(try file.getEndPos()); |
| 61 | | 69 | |
| 62 | const file_w = file.writer(); | 70 | const file_w = file.writer(); |
| 63 | try file_w.print("\n", .{}); | 71 | try file_w.print("\n", .{}); |
| 64 | try file_w.print(" - src: git {s}\n", .{std.mem.trimRight(u8, found.git, ".git")}); | 72 | try file_w.print(" - src: git {s}\n", .{std.mem.trimRight(u8, found.git, ".git")}); |
| 65 | try file_w.print(" name: {s}\n", .{found.name}); | 73 | if (!has_zigdotmod) { |
| 66 | try file_w.print(" main: {s}\n", .{found.root_file.?[1..]}); | 74 | try file_w.print(" name: {s}\n", .{found.name}); |
| | 75 | try file_w.print(" main: {s}\n", .{found.root_file.?[1..]}); |
| | 76 | } |
| 67 | | 77 | |
| 68 | std.log.info("Successfully added package {s} by {s}", .{ found.name, found.author }); | 78 | std.log.info("Successfully added package {s} by {s}", .{ found.name, found.author }); |
| 69 | } | 79 | } |