aboutsummaryrefslogtreecommitdiff
path: root/src/install/npm.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/install/npm.zig')
-rw-r--r--src/install/npm.zig23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/install/npm.zig b/src/install/npm.zig
index 78d0f6061..4cf1c2b71 100644
--- a/src/install/npm.zig
+++ b/src/install/npm.zig
@@ -327,12 +327,18 @@ pub const OperatingSystem = enum(u16) {
return (@intFromEnum(this) & linux) != 0;
} else if (comptime Environment.isMac) {
return (@intFromEnum(this) & darwin) != 0;
+ } else if (comptime Environment.isWindows) {
+ return (@intFromEnum(this) & win32) != 0;
} else {
return false;
}
}
- const NameMap = ComptimeStringMap(u16, .{
+ pub inline fn has(this: OperatingSystem, other: u16) bool {
+ return (@intFromEnum(this) & other) != 0;
+ }
+
+ pub const NameMap = ComptimeStringMap(u16, .{
.{ "aix", aix },
.{ "darwin", darwin },
.{ "freebsd", freebsd },
@@ -383,7 +389,7 @@ pub const Architecture = enum(u16) {
pub const all_value: u16 = arm | arm64 | ia32 | mips | mipsel | ppc | ppc64 | s390 | s390x | x32 | x64;
- const NameMap = ComptimeStringMap(u16, .{
+ pub const NameMap = ComptimeStringMap(u16, .{
.{ "arm", arm },
.{ "arm64", arm64 },
.{ "ia32", ia32 },
@@ -397,6 +403,10 @@ pub const Architecture = enum(u16) {
.{ "x64", x64 },
});
+ pub inline fn has(this: Architecture, other: u16) bool {
+ return (@intFromEnum(this) & other) != 0;
+ }
+
pub fn isMatch(this: Architecture) bool {
if (comptime Environment.isAarch64) {
return (@intFromEnum(this) & arm64) != 0;
@@ -800,7 +810,14 @@ pub const PackageManifest = struct {
if (this.findByDistTag("latest")) |result| {
if (group.satisfies(result.version)) {
- return result;
+ if (group.flags.isSet(Semver.Query.Group.Flags.pre)) {
+ if (left.version.order(result.version, this.string_buf, this.string_buf) == .eq) {
+ // if prerelease, use latest if semver+tag match range exactly
+ return result;
+ }
+ } else {
+ return result;
+ }
}
}