diff options
author | 2023-02-16 14:01:07 -0800 | |
---|---|---|
committer | 2023-02-16 14:01:07 -0800 | |
commit | 7762f3fad739e7c50f0ebe29b22b55a8daf7f559 (patch) | |
tree | f2c768685b36365bfec97d39112cc11dac19d68d /test/bun.js/fs.test.js | |
parent | e7cd45d0fa3f381238ea2ebfbba2d9e738376fcc (diff) | |
download | bun-7762f3fad739e7c50f0ebe29b22b55a8daf7f559.tar.gz bun-7762f3fad739e7c50f0ebe29b22b55a8daf7f559.tar.zst bun-7762f3fad739e7c50f0ebe29b22b55a8daf7f559.zip |
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.
Diffstat (limited to '')
-rw-r--r-- | test/bun.js/fs.test.js | 7 |
1 files changed, 7 insertions, 0 deletions
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); +}); |