| author | |
| committer | |
| log | 09d633b1405c5cbd4e02f4c86cb34f0368bf321f |
| tree | a34fe5cbe0608b20ef5509bbd6258ecad9ac1042 |
| parent | 65666d00836654f33ac4405acc12ccf50f93a071 |
6 files changed, 19 insertions(+), 6 deletions(-)
src/cmd/ci.zig+2-1| ... | @@ -2,6 +2,7 @@ const std = @import("std"); | ... | @@ -2,6 +2,7 @@ const std = @import("std"); |
| 2 | const string = []const u8; | 2 | const string = []const u8; |
| 3 | 3 | ||
| 4 | const zigmod = @import("../lib.zig"); | 4 | const zigmod = @import("../lib.zig"); |
| 5 | const u = @import("./../util/index.zig"); | ||
| 5 | const common = @import("./../common.zig"); | 6 | const common = @import("./../common.zig"); |
| 6 | 7 | ||
| 7 | // Inspired by: | 8 | // Inspired by: |
| ... | @@ -12,7 +13,7 @@ pub fn execute(self_name: []const u8, args: [][]u8) !void { | ... | @@ -12,7 +13,7 @@ pub fn execute(self_name: []const u8, args: [][]u8) !void { |
| 12 | _ = args; | 13 | _ = args; |
| 13 | 14 | ||
| 14 | const gpa = std.heap.c_allocator; | 15 | const gpa = std.heap.c_allocator; |
| 15 | const cachepath = try std.fs.path.join(gpa, &.{ ".zigmod", "deps" }); | 16 | const cachepath = try u.find_cachepath(); |
| 16 | const dir = std.fs.cwd(); | 17 | const dir = std.fs.cwd(); |
| 17 | try do(gpa, cachepath, dir); | 18 | try do(gpa, cachepath, dir); |
| 18 | } | 19 | } |
src/cmd/fetch.zig+1-2| ... | @@ -13,9 +13,8 @@ const license = @import("./license.zig"); | ... | @@ -13,9 +13,8 @@ const license = @import("./license.zig"); |
| 13 | pub fn execute(self_name: []const u8, args: [][]u8) !void { | 13 | pub fn execute(self_name: []const u8, args: [][]u8) !void { |
| 14 | _ = self_name; | 14 | _ = self_name; |
| 15 | 15 | ||
| 16 | // | ||
| 17 | const gpa = std.heap.c_allocator; | 16 | const gpa = std.heap.c_allocator; |
| 18 | const cachepath = try std.fs.path.join(gpa, &.{ ".zigmod", "deps" }); | 17 | const cachepath = try u.find_cachepath(); |
| 19 | const dir = std.fs.cwd(); | 18 | const dir = std.fs.cwd(); |
| 20 | const should_update = !(args.len >= 1 and std.mem.eql(u8, args[0], "--no-update")); | 19 | const should_update = !(args.len >= 1 and std.mem.eql(u8, args[0], "--no-update")); |
| 21 | 20 |
src/cmd/generate.zig+1-1| ... | @@ -14,7 +14,7 @@ pub fn execute(self_name: []const u8, args: [][]u8) !void { | ... | @@ -14,7 +14,7 @@ pub fn execute(self_name: []const u8, args: [][]u8) !void { |
| 14 | 14 | ||
| 15 | // | 15 | // |
| 16 | const gpa = std.heap.c_allocator; | 16 | const gpa = std.heap.c_allocator; |
| 17 | const cachepath = try std.fs.path.join(gpa, &.{ ".zigmod", "deps" }); | 17 | const cachepath = try u.find_cachepath(); |
| 18 | const dir = std.fs.cwd(); | 18 | const dir = std.fs.cwd(); |
| 19 | 19 | ||
| 20 | var options = common.CollectOptions{ | 20 | var options = common.CollectOptions{ |
src/cmd/license.zig+2-1| ... | @@ -6,6 +6,7 @@ const licenses = @import("licenses"); | ... | @@ -6,6 +6,7 @@ const licenses = @import("licenses"); |
| 6 | const extras = @import("extras"); | 6 | const extras = @import("extras"); |
| 7 | 7 | ||
| 8 | const zigmod = @import("../lib.zig"); | 8 | const zigmod = @import("../lib.zig"); |
| 9 | const u = @import("./../util/index.zig"); | ||
| 9 | const common = @import("./../common.zig"); | 10 | const common = @import("./../common.zig"); |
| 10 | 11 | ||
| 11 | const List = std.ArrayList(zigmod.Module); | 12 | const List = std.ArrayList(zigmod.Module); |
| ... | @@ -18,7 +19,7 @@ pub fn execute(self_name: []const u8, args: [][]u8) !void { | ... | @@ -18,7 +19,7 @@ pub fn execute(self_name: []const u8, args: [][]u8) !void { |
| 18 | _ = self_name; | 19 | _ = self_name; |
| 19 | _ = args; | 20 | _ = args; |
| 20 | 21 | ||
| 21 | const cachepath = try std.fs.path.join(gpa, &.{ ".zigmod", "deps" }); | 22 | const cachepath = try u.find_cachepath(); |
| 22 | const dir = std.fs.cwd(); | 23 | const dir = std.fs.cwd(); |
| 23 | 24 | ||
| 24 | var options = common.CollectOptions{ | 25 | var options = common.CollectOptions{ |
src/cmd/sum.zig+2-1| ... | @@ -2,6 +2,7 @@ const std = @import("std"); | ... | @@ -2,6 +2,7 @@ const std = @import("std"); |
| 2 | const gpa = std.heap.c_allocator; | 2 | const gpa = std.heap.c_allocator; |
| 3 | 3 | ||
| 4 | const zigmod = @import("../lib.zig"); | 4 | const zigmod = @import("../lib.zig"); |
| 5 | const u = @import("./../util/index.zig"); | ||
| 5 | const common = @import("./../common.zig"); | 6 | const common = @import("./../common.zig"); |
| 6 | 7 | ||
| 7 | // | 8 | // |
| ... | @@ -11,7 +12,7 @@ pub fn execute(self_name: []const u8, args: [][]u8) !void { | ... | @@ -11,7 +12,7 @@ pub fn execute(self_name: []const u8, args: [][]u8) !void { |
| 11 | _ = self_name; | 12 | _ = self_name; |
| 12 | _ = args; | 13 | _ = args; |
| 13 | 14 | ||
| 14 | const cachepath = try std.fs.path.join(gpa, &.{ ".zigmod", "deps" }); | 15 | const cachepath = try u.find_cachepath(); |
| 15 | const dir = std.fs.cwd(); | 16 | const dir = std.fs.cwd(); |
| 16 | 17 | ||
| 17 | var options = common.CollectOptions{ | 18 | var options = common.CollectOptions{ |
src/util/funcs.zig+11| ... | @@ -1,5 +1,6 @@ | ... | @@ -1,5 +1,6 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const string = []const u8; | 2 | const string = []const u8; |
| 3 | const gpa = std.heap.c_allocator; | ||
| 3 | const extras = @import("extras"); | 4 | const extras = @import("extras"); |
| 4 | 5 | ||
| 5 | const u = @import("index.zig"); | 6 | const u = @import("index.zig"); |
| ... | @@ -250,3 +251,13 @@ pub fn indexOfAfter(haystack: string, needle: u8, after: usize) ?usize { | ... | @@ -250,3 +251,13 @@ pub fn indexOfAfter(haystack: string, needle: u8, after: usize) ?usize { |
| 250 | } | 251 | } |
| 251 | return null; | 252 | return null; |
| 252 | } | 253 | } |
| 254 | |||
| 255 | pub fn find_cachepath() !string { | ||
| 256 | const haystack = try std.fs.cwd().realpathAlloc(gpa, "."); | ||
| 257 | const needle = "/.zigmod/deps"; | ||
| 258 | |||
| 259 | if (std.mem.indexOf(u8, haystack, needle)) |index| { | ||
| 260 | return haystack[0 .. index + needle.len]; | ||
| 261 | } | ||
| 262 | return try std.fs.path.join(gpa, &.{ ".zigmod", "deps" }); | ||
| 263 | } |