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 {...@@ -68,19 +68,19 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module {
68 switch (d.type) {68 switch (d.type) {
69 .git => {69 .git => {
70 if (!try u.does_file_exist(p)) {70 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});
72 }72 }
73 else {73 else {
74 try run_cmd(p, &[_][]const u8{"git", "fetch"});74 _ = try run_cmd(p, &[_][]const u8{"git", "fetch"});
75 try run_cmd(p, &[_][]const u8{"git", "pull"});75 _ = try run_cmd(p, &[_][]const u8{"git", "pull"});
76 }76 }
77 },77 },
78 .hg => {78 .hg => {
79 if (!try u.does_file_exist(p)) {79 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});
81 }81 }
82 else {82 else {
83 try run_cmd(p, &[_][]const u8{"hg", "pull"});83 _= try run_cmd(p, &[_][]const u8{"hg", "pull"});
84 }84 }
85 },85 },
86 }86 }
...@@ -116,13 +116,15 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module {...@@ -116,13 +116,15 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module {
116 };116 };
117}117}
118118
119fn run_cmd(dir: ?[]const u8, args: []const []const u8) !void {119fn run_cmd(dir: ?[]const u8, args: []const []const u8) !u32 {
120 _ = std.ChildProcess.exec(.{ .allocator = gpa, .cwd = dir, .argv = args, }) catch |e| switch(e) {120 const result = std.ChildProcess.exec(.{ .allocator = gpa, .cwd = dir, .argv = args, }) catch |e| switch(e) {
121 error.FileNotFound => {121 error.FileNotFound => {
122 u.assert(false, "\"{}\" command not found", .{args[0]});122 u.assert(false, "\"{}\" command not found", .{args[0]});
123 unreachable;
123 },124 },
124 else => return e,125 else => return e,
125 };126 };
127 return result.term.Exited;
126}128}
127129
128fn print_deps(w: std.fs.File.Writer, dir: []const u8, m: u.Module, tabs: i32) anyerror!void {130fn print_deps(w: std.fs.File.Writer, dir: []const u8, m: u.Module, tabs: i32) anyerror!void {