Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/parse.zig
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub fn parse(alloc: Allocator, deps: *StringHashMap(Dependency), file: File) !vo

var hash: ?[]const u8 = null;
var url: ?[]const u8 = null;
var has_path: bool = false;

var dep_buf: [2]Index = undefined;
const dep_init = ast.fullStructInit(&dep_buf, dep_idx) orelse {
Expand Down Expand Up @@ -85,14 +86,16 @@ pub fn parse(alloc: Allocator, deps: *StringHashMap(Dependency), file: File) !vo
}
} else if (mem.eql(u8, name, "hash")) {
hash = try parseString(alloc, ast, dep_field_idx);
} else if (mem.eql(u8, name, "path")) {
has_path = true;
}
}

if (url != null and hash != null) {
dep.url = url.?;
_ = try deps.getOrPutValue(hash.?, dep);
} else {
return error.parseError;
if (!has_path) return error.InvalidDependency;
}
}
}
Expand Down