authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-08-20 21:41:06 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-08-20 21:41:06 -07:00
log090a4e57e0f600139fdf7aa7971ece3ac00cb4b3
treef6eab6bc80f5b6d96f33bab0f35cb35298e1f1a7
parenta0f1d58a2b0f9cbe04288c5550e078ca57b98708

rework lockfile parsing to accept a Dir instead of a path


2 files changed, 4 insertions(+), 3 deletions(-)

src/cmd/ci.zig+2-1
...@@ -10,12 +10,13 @@ const common = @import("./../common.zig");...@@ -10,12 +10,13 @@ const common = @import("./../common.zig");
10pub fn execute(args: [][]u8) !void {10pub fn execute(args: [][]u8) !void {
11 _ = args;11 _ = args;
1212
13 const dir = std.fs.cwd();
13 const cachepath = try std.fs.path.join(gpa, &.{ ".zigmod", "deps" });14 const cachepath = try std.fs.path.join(gpa, &.{ ".zigmod", "deps" });
1415
15 var options = common.CollectOptions{16 var options = common.CollectOptions{
16 .log = true,17 .log = true,
17 .update = false,18 .update = false,
18 .lock = try common.parse_lockfile("zigmod.lock"),19 .lock = try common.parse_lockfile(dir),
19 };20 };
20 const top_module = try common.collect_deps_deep(cachepath, "zig.mod", &options);21 const top_module = try common.collect_deps_deep(cachepath, "zig.mod", &options);
2122
src/common.zig+2-2
...@@ -335,10 +335,10 @@ pub fn add_files_package(pkg_name: []const u8, dirs: []const []const u8, parent_...@@ -335,10 +335,10 @@ pub fn add_files_package(pkg_name: []const u8, dirs: []const []const u8, parent_
335 return (try get_module_from_dep(&d, destination, parent_name, &options)).?;335 return (try get_module_from_dep(&d, destination, parent_name, &options)).?;
336}336}
337337
338pub fn parse_lockfile(path: []const u8) ![]const [4][]const u8 {338pub fn parse_lockfile(dir: std.fs.Dir) ![]const [4][]const u8 {
339 var list = std.ArrayList([4][]const u8).init(gpa);339 var list = std.ArrayList([4][]const u8).init(gpa);
340 const max = std.math.maxInt(usize);340 const max = std.math.maxInt(usize);
341 const f = try std.fs.cwd().openFile(path, .{});341 const f = try dir.openFile("zigmod.lock", .{});
342 const r = f.reader();342 const r = f.reader();
343 var i: usize = 0;343 var i: usize = 0;
344 var v: usize = 1;344 var v: usize = 1;