chore(zig): add a new lint for using bun.FD.cwd() (#10683)

This commit is contained in:
Meghan Denny
2024-05-01 16:12:09 -07:00
committed by GitHub
parent 5f4c5052d1
commit e45cd749e5
10 changed files with 16 additions and 14 deletions

View File

@@ -2867,7 +2867,7 @@ pub const Arguments = struct {
.flag = flag,
.mode = mode,
.data = data,
.dirfd = bun.toFD(std.fs.cwd().fd),
.dirfd = bun.FD.cwd(),
};
}
};
@@ -4803,7 +4803,7 @@ pub const NodeFS = struct {
) Maybe(void) {
const flags = os.O.DIRECTORY | os.O.RDONLY;
const atfd = if (comptime is_root) bun.toFD(std.fs.cwd().fd) else async_task.root_fd;
const atfd = if (comptime is_root) bun.FD.cwd() else async_task.root_fd;
const fd = switch (switch (Environment.os) {
else => Syscall.openat(atfd, basename, flags, 0),
// windows bun.sys.open does not pass iterable=true,
@@ -4953,7 +4953,7 @@ pub const NodeFS = struct {
}
const flags = os.O.DIRECTORY | os.O.RDONLY;
const fd = switch (Syscall.openat(if (root_fd == bun.invalid_fd) bun.toFD(std.fs.cwd().fd) else root_fd, basename, flags, 0)) {
const fd = switch (Syscall.openat(if (root_fd == bun.invalid_fd) bun.FD.cwd() else root_fd, basename, flags, 0)) {
.err => |err| {
if (root_fd == bun.invalid_fd) {
return .{
@@ -5101,7 +5101,7 @@ pub const NodeFS = struct {
const fd = switch (switch (Environment.os) {
else => Syscall.open(path, flags, 0),
// windows bun.sys.open does not pass iterable=true,
.windows => bun.sys.openDirAtWindowsA(bun.toFD(std.fs.cwd().fd), path, .{ .iterable = true, .read_only = true }),
.windows => bun.sys.openDirAtWindowsA(bun.FD.cwd(), path, .{ .iterable = true, .read_only = true }),
}) {
.err => |err| return .{
.err = err.withPath(args.path.slice()),
@@ -6555,7 +6555,7 @@ pub const NodeFS = struct {
}
const open_flags = os.O.DIRECTORY | os.O.RDONLY;
const fd = switch (Syscall.openatOSPath(bun.toFD(std.fs.cwd().fd), src, open_flags, 0)) {
const fd = switch (Syscall.openatOSPath(bun.FD.cwd(), src, open_flags, 0)) {
.err => |err| {
task.finishConcurrently(.{ .err = err.withPath(this.osPathIntoSyncErrorBuf(src)) });
return false;