authorgravatar for hello@nektro.netMeghan <hello@nektro.net> 2020-11-20 11:27:06 -08:00
committergravatar for hello@nektro.netMeghan <hello@nektro.net> 2020-11-20 11:27:06 -08:00
log6b900c97b80d9c419b2b6a1ff59ea71fc5200adc
tree4fe5b1b930479f9f9cf6608c622dbbbcac599f9b
parent868105a6cf4c075037d365f18171a52b75f61a3f

fetch: make run_cmd return the exit code


1 files changed, 9 insertions(+), 7 deletions(-)

src/cmd_fetch.zig+9-7
......@@ -68,19 +68,19 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module {
6868 switch (d.type) {
6969 .git => {
7070 if (!try u.does_file_exist(p)) {
71 try run_cmd(null, &[_][]const u8{"git", "clone", d.path, p});
71 _ = try run_cmd(null, &[_][]const u8{"git", "clone", d.path, p});
7272 }
7373 else {
74 try run_cmd(p, &[_][]const u8{"git", "fetch"});
75 try run_cmd(p, &[_][]const u8{"git", "pull"});
74 _ = try run_cmd(p, &[_][]const u8{"git", "fetch"});
75 _ = try run_cmd(p, &[_][]const u8{"git", "pull"});
7676 }
7777 },
7878 .hg => {
7979 if (!try u.does_file_exist(p)) {
80 try run_cmd(null, &[_][]const u8{"hg", "clone", d.path, p});
80 _= try run_cmd(null, &[_][]const u8{"hg", "clone", d.path, p});
8181 }
8282 else {
83 try run_cmd(p, &[_][]const u8{"hg", "pull"});
83 _= try run_cmd(p, &[_][]const u8{"hg", "pull"});
8484 }
8585 },
8686 }
......@@ -116,13 +116,15 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module {
116116 };
117117}
118118
119fn run_cmd(dir: ?[]const u8, args: []const []const u8) !void {
120 _ = std.ChildProcess.exec(.{ .allocator = gpa, .cwd = dir, .argv = args, }) catch |e| switch(e) {
119fn run_cmd(dir: ?[]const u8, args: []const []const u8) !u32 {
120 const result = std.ChildProcess.exec(.{ .allocator = gpa, .cwd = dir, .argv = args, }) catch |e| switch(e) {
121121 error.FileNotFound => {
122122 u.assert(false, "\"{}\" command not found", .{args[0]});
123 unreachable;
123124 },
124125 else => return e,
125126 };
127 return result.term.Exited;
126128}
127129
128130fn print_deps(w: std.fs.File.Writer, dir: []const u8, m: u.Module, tabs: i32) anyerror!void {