From 6b900c97b80d9c419b2b6a1ff59ea71fc5200adc Mon Sep 17 00:00:00 2001 From: Meghan Date: Fri, 20 Nov 2020 11:27:06 -0800 Subject: [PATCH] fetch: make run_cmd return the exit code --- src/cmd_fetch.zig | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/cmd_fetch.zig b/src/cmd_fetch.zig index 4d91c605f2acfbc4e61cde94837161c7cc7e75a9..68292036f5c5cceec1a473a36a830ea921999ab2 100644 --- a/src/cmd_fetch.zig +++ b/src/cmd_fetch.zig @@ -68,19 +68,19 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module { switch (d.type) { .git => { if (!try u.does_file_exist(p)) { - try run_cmd(null, &[_][]const u8{"git", "clone", d.path, p}); + _ = try run_cmd(null, &[_][]const u8{"git", "clone", d.path, p}); } else { - try run_cmd(p, &[_][]const u8{"git", "fetch"}); - try run_cmd(p, &[_][]const u8{"git", "pull"}); + _ = try run_cmd(p, &[_][]const u8{"git", "fetch"}); + _ = try run_cmd(p, &[_][]const u8{"git", "pull"}); } }, .hg => { if (!try u.does_file_exist(p)) { - try run_cmd(null, &[_][]const u8{"hg", "clone", d.path, p}); + _= try run_cmd(null, &[_][]const u8{"hg", "clone", d.path, p}); } else { - try run_cmd(p, &[_][]const u8{"hg", "pull"}); + _= try run_cmd(p, &[_][]const u8{"hg", "pull"}); } }, } @@ -116,13 +116,15 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module { }; } -fn run_cmd(dir: ?[]const u8, args: []const []const u8) !void { - _ = std.ChildProcess.exec(.{ .allocator = gpa, .cwd = dir, .argv = args, }) catch |e| switch(e) { +fn run_cmd(dir: ?[]const u8, args: []const []const u8) !u32 { + const result = std.ChildProcess.exec(.{ .allocator = gpa, .cwd = dir, .argv = args, }) catch |e| switch(e) { error.FileNotFound => { u.assert(false, "\"{}\" command not found", .{args[0]}); + unreachable; }, else => return e, }; + return result.term.Exited; } fn print_deps(w: std.fs.File.Writer, dir: []const u8, m: u.Module, tabs: i32) anyerror!void { -- 2.54.0