From 7762f3fad739e7c50f0ebe29b22b55a8daf7f559 Mon Sep 17 00:00:00 2001 From: Justin Whear Date: Thu, 16 Feb 2023 14:01:07 -0800 Subject: Fix #1516 (#2089) `FileSystemFlags.fromJS` was hardcoded to return O_RDONLY when the flag value was null or undefined and this caused breakage when used with write functions. Updated the function to take a `default` argument so that the caller can specify a sane default for their use. --- test/bun.js/fs.test.js | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test/bun.js') diff --git a/test/bun.js/fs.test.js b/test/bun.js/fs.test.js index 086f19211..5e4827672 100644 --- a/test/bun.js/fs.test.js +++ b/test/bun.js/fs.test.js @@ -987,3 +987,10 @@ it("fs.Dirent", () => { it("fs.Stats", () => { expect(Stats).toBeDefined(); }); + +it("repro 1516: can use undefined/null to specify default flag", () => { + const path = "/tmp/repro_1516.txt"; + writeFileSync(path, "b", { flag: undefined }); + expect(readFileSync(path, { encoding: "utf8", flag: null })).toBe("b"); + rmSync(path); +}); -- cgit v1.2.3