authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-07-10 16:13:54 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-07-10 16:13:54 -07:00
log4369779330109bf0d0af86d95ae969bb844a995d
treeaca16bb938f5040908f7aff8117efe563d8380db
parent4b04e9feee75c7c7383217db811900a280ce0cde

cmd/fetch- attempt using `detct_mainfile` when dep has no zig.mod


1 files changed, 14 insertions(+), 0 deletions(-)

src/common.zig+14
......@@ -224,6 +224,20 @@ pub fn get_module_from_dep(d: *u.Dep, dir: []const u8, parent_name: []const u8,
224224 if (mod_from.is_for_this()) return mod_from;
225225 return null;
226226 }
227 const moddirO = try std.fs.cwd().openDir(moddir, .{});
228 const tryname = try u.detect_pkgname("", moddirO);
229 const trymain = u.detct_mainfile("", moddirO, tryname) catch |err| switch (err) {
230 error.CantFindMain => null,
231 else => return err,
232 };
233 if (trymain) |_| {
234 d.*.name = tryname;
235 d.*.main = trymain.?;
236 var mod_from = try u.Module.from(d.*, dir, options);
237 if (d.type != .local) mod_from.clean_path = u.trim_prefix(moddir, dir)[1..];
238 if (mod_from.is_for_this()) return mod_from;
239 return null;
240 }
227241 u.assert(false, "no zig.mod found and no override props defined. unable to use add this dependency!", .{});
228242 unreachable;
229243 },