i dont like windows anymore

This commit is contained in:
RiskyMH
2025-07-25 04:46:30 +10:00
parent 3829b62c8e
commit ee0af66e4a

View File

@@ -522,7 +522,13 @@ pub const NodeCommand = struct {
const version_binary = try std.fmt.allocPrintZ(allocator, "{s}/" ++ node_binary_name, .{version_dir});
defer allocator.free(version_binary);
if (bun.sys.access(version_binary, 0) == .result) {
const access_result = if (Env.isWindows) blk: {
var buf: bun.OSPathBuffer = undefined;
const path = bun.strings.toWPathNormalized(&buf, version_binary);
break :blk bun.sys.access(path, 0);
} else bun.sys.access(version_binary, 0);
if (access_result == .result) {
if (set_as_default) {
Output.prettyln("<r><green>✓<r> Node.js v{s} is already installed", .{version});
}
@@ -567,7 +573,13 @@ pub const NodeCommand = struct {
const version_binary = try std.fmt.allocPrintZ(allocator, "{s}/node-{s}/" ++ node_binary_name, .{ cache_dir, version });
defer allocator.free(version_binary);
if (bun.sys.access(version_binary, 0) != .result) {
const access_result2 = if (Env.isWindows) blk: {
var buf: bun.OSPathBuffer = undefined;
const path = bun.strings.toWPathNormalized(&buf, version_binary);
break :blk bun.sys.access(path, 0);
} else bun.sys.access(version_binary, 0);
if (access_result2 != .result) {
const version_dir = try std.fmt.allocPrint(allocator, "{s}/node-{s}", .{ cache_dir, version });
defer allocator.free(version_dir);
@@ -720,7 +732,13 @@ pub const NodeCommand = struct {
const version_binaryZ3 = try allocator.dupeZ(u8, version_binary);
defer allocator.free(version_binaryZ3);
if (bun.sys.access(version_binaryZ3, 0) == .result) {
const access_result3 = if (Env.isWindows) blk: {
var buf: bun.OSPathBuffer = undefined;
const path = bun.strings.toWPathNormalized(&buf, version_binary);
break :blk bun.sys.access(path, 0);
} else bun.sys.access(version_binaryZ3, 0);
if (access_result3 == .result) {
try runNode(allocator, version_binary, args);
} else {
try installNodeVersion(ctx, version_spec, false);
@@ -737,7 +755,13 @@ pub const NodeCommand = struct {
const node_symlink = try std.fs.path.joinZ(allocator, &.{ bin_dir, node_binary_name });
defer allocator.free(node_symlink);
if (bun.sys.access(node_symlink, 0) == .result) {
const access_result4 = if (Env.isWindows) blk: {
var buf: bun.OSPathBuffer = undefined;
const path = bun.strings.toWPathNormalized(&buf, node_symlink);
break :blk bun.sys.access(path, 0);
} else bun.sys.access(node_symlink, 0);
if (access_result4 == .result) {
try runNode(allocator, node_symlink, args);
return;
}
@@ -896,7 +920,13 @@ pub const NodeCommand = struct {
} else if (entry.len > 0) {
const test_node = try std.fs.path.joinZ(allocator, &.{ entry, "node" });
defer allocator.free(test_node);
if (bun.sys.access(test_node, 0) == .result) {
const access_result5 = if (Env.isWindows) blk: {
var buf: bun.OSPathBuffer = undefined;
const path = bun.strings.toWPathNormalized(&buf, test_node);
break :blk bun.sys.access(path, 0);
} else bun.sys.access(test_node, 0);
if (access_result5 == .result) {
found_other_dir = true;
}
}