authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-05-07 03:42:25 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-05-07 03:42:25 -07:00
log70bb35dc54fb157da9576e9d919f544ac9d4405c
tree7591d88f72bced49c5f6536fe5fdabb286cb3dae
parent29460c33bd91ab7169f9edeb789f9009ffe56e87

cmd/fetch: add --no-update flag


2 files changed, 7 insertions(+), 6 deletions(-)

src/cmd/fetch.zig+3-2
......@@ -12,10 +12,11 @@ const common = @import("./../common.zig");
1212pub fn execute(args: [][]u8) !void {
1313 //
1414 const dir = try fs.path.join(gpa, &.{ ".zigmod", "deps" });
15 const should_update = !(args.len >= 1 and std.mem.eql(u8, args[0], "--no-update"));
1516
1617 const top_module = try common.collect_deps_deep(dir, "zig.mod", .{
17 .log = true,
18 .update = true,
18 .log = should_update,
19 .update = should_update,
1920 });
2021
2122 //
src/common.zig+4-4
......@@ -12,7 +12,7 @@ pub const CollectOptions = struct {
1212 update: bool,
1313};
1414
15pub fn collect_deps_deep(dir: []const u8, mpath: []const u8, comptime options: CollectOptions) !u.Module {
15pub fn collect_deps_deep(dir: []const u8, mpath: []const u8, options: CollectOptions) !u.Module {
1616 const m = try u.ModFile.init(gpa, mpath);
1717 const moduledeps = &std.ArrayList(u.Module).init(gpa);
1818 try moduledeps.append(try collect_deps(dir, mpath, options));
......@@ -35,7 +35,7 @@ pub fn collect_deps_deep(dir: []const u8, mpath: []const u8, comptime options: C
3535 };
3636}
3737
38pub fn collect_deps(dir: []const u8, mpath: []const u8, comptime options: CollectOptions) anyerror!u.Module {
38pub fn collect_deps(dir: []const u8, mpath: []const u8, options: CollectOptions) anyerror!u.Module {
3939 const m = try u.ModFile.init(gpa, mpath);
4040 const moduledeps = &std.ArrayList(u.Module).init(gpa);
4141 for (m.deps) |d| {
......@@ -67,7 +67,7 @@ pub fn collect_pkgs(mod: u.Module, list: *std.ArrayList(u.Module)) anyerror!void
6767 }
6868}
6969
70fn get_moddir(basedir: []const u8, d: u.Dep, parent_name: []const u8, comptime options: CollectOptions) ![]const u8 {
70fn get_moddir(basedir: []const u8, d: u.Dep, parent_name: []const u8, options: CollectOptions) ![]const u8 {
7171 const p = try fs.path.join(gpa, &.{ basedir, try d.clean_path() });
7272 const pv = try fs.path.join(gpa, &.{ basedir, try d.clean_path_v() });
7373 const tempdir = try fs.path.join(gpa, &.{ basedir, "temp" });
......@@ -159,7 +159,7 @@ fn get_moddir(basedir: []const u8, d: u.Dep, parent_name: []const u8, comptime o
159159 }
160160}
161161
162fn get_module_from_dep(list: *std.ArrayList(u.Module), d: u.Dep, dir: []const u8, parent_name: []const u8, comptime options: CollectOptions) !void {
162fn get_module_from_dep(list: *std.ArrayList(u.Module), d: u.Dep, dir: []const u8, parent_name: []const u8, options: CollectOptions) !void {
163163 const moddir = try get_moddir(dir, d, parent_name, options);
164164 switch (d.type) {
165165 .system_lib => {