diff options
author | 2023-01-31 03:04:59 -0800 | |
---|---|---|
committer | 2023-01-31 03:04:59 -0800 | |
commit | 4bfdad298148196beb43f1f9fd6fe2bb556cce3f (patch) | |
tree | ef2a67272043870dfa8bc5d767c508cdca77e637 | |
parent | 3ddd8b2fa508c9c4558dfbb9c083929b5960385b (diff) | |
download | bun-4bfdad298148196beb43f1f9fd6fe2bb556cce3f.tar.gz bun-4bfdad298148196beb43f1f9fd6fe2bb556cce3f.tar.zst bun-4bfdad298148196beb43f1f9fd6fe2bb556cce3f.zip |
Fix missing `*ms` getters in Stat
Related to #1949
-rw-r--r-- | src/bun.js/node/types.zig | 24 | ||||
-rw-r--r-- | test/bun.js/fs.test.js | 18 |
2 files changed, 30 insertions, 12 deletions
diff --git a/src/bun.js/node/types.zig b/src/bun.js/node/types.zig index a1cf3208c..5628e8ec8 100644 --- a/src/bun.js/node/types.zig +++ b/src/bun.js/node/types.zig @@ -1141,19 +1141,19 @@ fn StatsLike(comptime name: [:0]const u8, comptime T: type) type { .get = JSC.To.JS.Getter(This, .birthtime), .name = "birthtime", }, - .atime_ms = .{ + .atimeMs = .{ .get = JSC.To.JS.Getter(This, .atime_ms), .name = "atimeMs", }, - .mtime_ms = .{ + .mtimeMs = .{ .get = JSC.To.JS.Getter(This, .mtime_ms), .name = "mtimeMs", }, - .ctime_ms = .{ + .ctimeMs = .{ .get = JSC.To.JS.Getter(This, .ctime_ms), .name = "ctimeMs", }, - .birthtime_ms = .{ + .birthtimeMs = .{ .get = JSC.To.JS.Getter(This, .birthtime_ms), .name = "birthtimeMs", }, @@ -1215,27 +1215,27 @@ fn StatsLike(comptime name: [:0]const u8, comptime T: type) type { }; } - pub fn isBlockDevice(this: *Stats) JSC.JSValue { + pub fn isBlockDevice(this: *This) JSC.JSValue { return JSC.JSValue.jsBoolean(os.S.ISBLK(@intCast(Mode, this.mode))); } - pub fn isCharacterDevice(this: *Stats) JSC.JSValue { + pub fn isCharacterDevice(this: *This) JSC.JSValue { return JSC.JSValue.jsBoolean(os.S.ISCHR(@intCast(Mode, this.mode))); } - pub fn isDirectory(this: *Stats) JSC.JSValue { + pub fn isDirectory(this: *This) JSC.JSValue { return JSC.JSValue.jsBoolean(os.S.ISDIR(@intCast(Mode, this.mode))); } - pub fn isFIFO(this: *Stats) JSC.JSValue { + pub fn isFIFO(this: *This) JSC.JSValue { return JSC.JSValue.jsBoolean(os.S.ISFIFO(@intCast(Mode, this.mode))); } - pub fn isFile(this: *Stats) JSC.JSValue { + pub fn isFile(this: *This) JSC.JSValue { return JSC.JSValue.jsBoolean(os.S.ISREG(@intCast(Mode, this.mode))); } - pub fn isSocket(this: *Stats) JSC.JSValue { + pub fn isSocket(this: *This) JSC.JSValue { return JSC.JSValue.jsBoolean(os.S.ISSOCK(@intCast(Mode, this.mode))); } @@ -1244,7 +1244,7 @@ fn StatsLike(comptime name: [:0]const u8, comptime T: type) type { // still just return false. // // See https://nodejs.org/api/fs.html#statsissymboliclink - pub fn isSymbolicLink(this: *Stats) JSC.JSValue { + pub fn isSymbolicLink(this: *This) JSC.JSValue { return JSC.JSValue.jsBoolean(os.S.ISLNK(@intCast(Mode, this.mode))); } @@ -1254,7 +1254,7 @@ fn StatsLike(comptime name: [:0]const u8, comptime T: type) type { return Class.make(ctx, _this); } - pub fn finalize(this: *Stats) void { + pub fn finalize(this: *This) void { bun.default_allocator.destroy(this); } }; diff --git a/test/bun.js/fs.test.js b/test/bun.js/fs.test.js index 865f6f16a..0150eaf7d 100644 --- a/test/bun.js/fs.test.js +++ b/test/bun.js/fs.test.js @@ -439,6 +439,24 @@ describe("stat", () => { expect(fileStats.isSymbolicLink()).toBe(false); expect(fileStats.isFile()).toBe(false); expect(fileStats.isDirectory()).toBe(true); + expect(typeof fileStats.dev).toBe("number"); + expect(typeof fileStats.ino).toBe("number"); + expect(typeof fileStats.mode).toBe("number"); + expect(typeof fileStats.nlink).toBe("number"); + expect(typeof fileStats.uid).toBe("number"); + expect(typeof fileStats.gid).toBe("number"); + expect(typeof fileStats.rdev).toBe("number"); + expect(typeof fileStats.size).toBe("number"); + expect(typeof fileStats.blksize).toBe("number"); + expect(typeof fileStats.blocks).toBe("number"); + expect(typeof fileStats.atimeMs).toBe("number"); + expect(typeof fileStats.mtimeMs).toBe("number"); + expect(typeof fileStats.ctimeMs).toBe("number"); + expect(typeof fileStats.birthtimeMs).toBe("number"); + expect(typeof fileStats.atime).toBe("object"); + expect(typeof fileStats.mtime).toBe("object"); + expect(typeof fileStats.ctime).toBe("object"); + expect(typeof fileStats.birthtime).toBe("object"); }); it("stat returns ENOENT", () => { |