| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8288f57 commit 8d485f1
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -944,6 +944,10 @@ async function readdirRecursive(originalPath, options) { | |||
| 944 | 944 | ||
| 945 | 945 | async function readdir(path, options) { | |
| 946 | 946 | options = getOptions(options); | |
| 947 | + | ||
| 948 | + // Make shallow copy to prevent mutating options from affecting results | ||
| 949 | + options = copyObject(options); | ||
| 950 | + | ||
| 947 | 951 | path = getValidatedPath(path); | |
| 948 | 952 | if (options.recursive) { | |
| 949 | 953 | return readdirRecursive(path, options); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -78,6 +78,14 @@ fs.readdir(readdirDir, { | |||
| 78 | 78 | assertDirents(dirents); | |
| 79 | 79 | })().then(common.mustCall()); | |
| 80 | 80 | ||
| 81 | + // Check that mutating options doesn't affect results | ||
| 82 | + (async () => { | ||
| 83 | + const options = { withFileTypes: true }; | ||
| 84 | + const direntsPromise = fs.promises.readdir(readdirDir, options); | ||
| 85 | + options.withFileTypes = false; | ||
| 86 | + assertDirents(await direntsPromise); | ||
| 87 | + })().then(common.mustCall()); | ||
| 88 | + | ||
| 81 | 89 | // Check for correct types when the binding returns unknowns | |
| 82 | 90 | const UNKNOWN = constants.UV_DIRENT_UNKNOWN; | |
| 83 | 91 | const oldReaddir = binding.readdir; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments