mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
fix: export constants from fs/promises (#2567)
* fix: export `constants` from `fs/promises` * fix type tests * third time's the charm fixing the typedef * run fmt * remove injected constant from fs, re-exporting from fs/promises
This commit is contained in:
@@ -87,7 +87,7 @@ This page is updated regularly to reflect compatibility status of the latest ver
|
||||
|
||||
- {% anchor id="node_fs" %} [`node:fs`](https://nodejs.org/api/fs.html) {% /anchor %}
|
||||
- 🟡
|
||||
- Missing `fs.constants` `fs.fdatasync{Sync}` `fs.opendir{Sync}` `fs.readv{Sync}` `fs.{watch|watchFile|unwatchFile}` `fs.writev{Sync}`.
|
||||
- Missing `fs.fdatasync{Sync}` `fs.opendir{Sync}` `fs.readv{Sync}` `fs.{watch|watchFile|unwatchFile}` `fs.writev{Sync}`.
|
||||
|
||||
---
|
||||
|
||||
|
||||
2
packages/bun-types/fs/promises.d.ts
vendored
2
packages/bun-types/fs/promises.d.ts
vendored
@@ -28,6 +28,8 @@ declare module "fs/promises" {
|
||||
RmDirOptions,
|
||||
} from "node:fs";
|
||||
|
||||
const constants: typeof import("node:fs")["constants"];
|
||||
|
||||
interface FlagAndOpenMode {
|
||||
mode?: Mode | undefined;
|
||||
flag?: OpenMode | undefined;
|
||||
|
||||
@@ -925,7 +925,7 @@ export default {
|
||||
chownSync,
|
||||
close,
|
||||
closeSync,
|
||||
constants,
|
||||
constants: promises.constants,
|
||||
copyFile,
|
||||
copyFileSync,
|
||||
createReadStream,
|
||||
|
||||
@@ -110,5 +110,6 @@ export default {
|
||||
lutimes,
|
||||
rm,
|
||||
rmdir,
|
||||
constants,
|
||||
[Symbol.for("CommonJS")]: 0,
|
||||
};
|
||||
|
||||
@@ -1672,7 +1672,7 @@ pub const ModuleLoader = struct {
|
||||
if (comptime Environment.isDebug) {
|
||||
return ResolvedSource{
|
||||
.allocator = null,
|
||||
.source_code = ZigString.init(strings.append(bun.default_allocator, JSC.Node.fs.constants_string, jsModuleFromFile(jsc_vm.load_builtins_from_path, "fs.exports.js")) catch unreachable),
|
||||
.source_code = ZigString.init(jsModuleFromFile(jsc_vm.load_builtins_from_path, "fs.exports.js")),
|
||||
.specifier = ZigString.init("node:fs"),
|
||||
.source_url = ZigString.init("node:fs"),
|
||||
.hash = 0,
|
||||
@@ -1680,7 +1680,7 @@ pub const ModuleLoader = struct {
|
||||
} else if (jsc_vm.load_builtins_from_path.len != 0) {
|
||||
return ResolvedSource{
|
||||
.allocator = null,
|
||||
.source_code = ZigString.init(strings.append(bun.default_allocator, JSC.Node.fs.constants_string, jsModuleFromFile(jsc_vm.load_builtins_from_path, "fs.exports.js")) catch unreachable),
|
||||
.source_code = ZigString.init(jsModuleFromFile(jsc_vm.load_builtins_from_path, "fs.exports.js")),
|
||||
.specifier = ZigString.init("node:fs"),
|
||||
.source_url = ZigString.init("node:fs"),
|
||||
.hash = 0,
|
||||
@@ -1689,7 +1689,7 @@ pub const ModuleLoader = struct {
|
||||
|
||||
return ResolvedSource{
|
||||
.allocator = null,
|
||||
.source_code = ZigString.init(JSC.Node.fs.constants_string ++ @embedFile("fs.exports.js")),
|
||||
.source_code = ZigString.init(@embedFile("fs.exports.js")),
|
||||
.specifier = ZigString.init("node:fs"),
|
||||
.source_url = ZigString.init("node:fs"),
|
||||
.hash = 0,
|
||||
@@ -1733,7 +1733,7 @@ pub const ModuleLoader = struct {
|
||||
.@"node:fs/promises" => {
|
||||
return ResolvedSource{
|
||||
.allocator = null,
|
||||
.source_code = ZigString.init(@embedFile("fs_promises.exports.js") ++ JSC.Node.fs.constants_string),
|
||||
.source_code = ZigString.init(JSC.Node.fs.constants_string ++ @embedFile("fs_promises.exports.js")),
|
||||
.specifier = ZigString.init("node:fs/promises"),
|
||||
.source_url = ZigString.init("node:fs/promises"),
|
||||
.hash = 0,
|
||||
|
||||
@@ -1093,6 +1093,11 @@ it("fs.constants", () => {
|
||||
expect(constants.S_IWOTH).toBeDefined();
|
||||
});
|
||||
|
||||
it("fs.promises.constants", () => {
|
||||
expect(promises.constants).toBeDefined();
|
||||
expect(promises.constants).toBe(fs.constants);
|
||||
});
|
||||
|
||||
it("fs.Dirent", () => {
|
||||
expect(Dirent).toBeDefined();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user