aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/install/dependency.zig13
-rw-r--r--src/install/lockfile.zig6
2 files changed, 16 insertions, 3 deletions
diff --git a/src/install/dependency.zig b/src/install/dependency.zig
index 8578e998a..3a9ee6b54 100644
--- a/src/install/dependency.zig
+++ b/src/install/dependency.zig
@@ -257,6 +257,14 @@ pub const Version = struct {
return strings.cmpStringsAsc({}, lhs.literal.slice(string_buf), rhs.literal.slice(string_buf));
}
+ pub fn isLessThanWithTag(string_buf: []const u8, lhs: Dependency.Version, rhs: Dependency.Version) bool {
+ const tag_order = lhs.tag.cmp(rhs.tag);
+ if (tag_order != .eq)
+ return tag_order == .lt;
+
+ return strings.cmpStringsAsc({}, lhs.literal.slice(string_buf), rhs.literal.slice(string_buf));
+ }
+
pub const External = [9]u8;
pub fn toVersion(
@@ -338,6 +346,11 @@ pub const Version = struct {
/// GitHub Repository (via REST API)
github = 8,
+ pub fn cmp(this: Tag, other: Tag) std.math.Order {
+ // TODO: align with yarn
+ return std.math.order(@intFromEnum(this), @intFromEnum(other));
+ }
+
pub inline fn isNPM(this: Tag) bool {
return @intFromEnum(this) < 3;
}
diff --git a/src/install/lockfile.zig b/src/install/lockfile.zig
index c224cc765..dbbb22300 100644
--- a/src/install/lockfile.zig
+++ b/src/install/lockfile.zig
@@ -942,8 +942,8 @@ pub const Printer = struct {
Global.crash();
},
.not_found => {
- Output.prettyErrorln("<r><red>lockfile not found:<r> {s}", .{
- std.mem.sliceAsBytes(lockfile_path),
+ Output.prettyErrorln("<r><red>lockfile not found:<r> {}", .{
+ strings.QuotedFormatter{ .text = std.mem.sliceAsBytes(lockfile_path) },
});
Global.crash();
},
@@ -1234,7 +1234,7 @@ pub const Printer = struct {
}
var dependency_versions = requested_version_start[0..j];
- if (dependency_versions.len > 1) std.sort.insertion(Dependency.Version, dependency_versions, string_buf, Dependency.Version.isLessThan);
+ if (dependency_versions.len > 1) std.sort.insertion(Dependency.Version, dependency_versions, string_buf, Dependency.Version.isLessThanWithTag);
try requested_versions.put(i, dependency_versions);
}
}