Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'test/parallel/test-fs-rmdir-recursive.js')
-rw-r--r--test/parallel/test-fs-rmdir-recursive.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/parallel/test-fs-rmdir-recursive.js b/test/parallel/test-fs-rmdir-recursive.js
index 1d2525a5ed6..bbf89a3959e 100644
--- a/test/parallel/test-fs-rmdir-recursive.js
+++ b/test/parallel/test-fs-rmdir-recursive.js
@@ -211,3 +211,28 @@ function removeAsync(dir) {
message: /^The value of "options\.maxRetries" is out of range\./
});
}
+
+// It should not pass recursive option to rmdirSync, when called from
+// rimraf (see: #35566)
+{
+ // Make a non-empty directory:
+ const original = fs.rmdirSync;
+ const dir = `${nextDirPath()}/foo/bar`;
+ fs.mkdirSync(dir, { recursive: true });
+ fs.writeFileSync(`${dir}/foo.txt`, 'hello world', 'utf8');
+
+ // When called the second time from rimraf, the recursive option should
+ // not be set for rmdirSync:
+ let callCount = 0;
+ let rmdirSyncOptionsFromRimraf;
+ fs.rmdirSync = (path, options) => {
+ if (callCount > 0) {
+ rmdirSyncOptionsFromRimraf = { ...options };
+ }
+ callCount++;
+ return original(path, options);
+ };
+ fs.rmdirSync(dir, { recursive: true });
+ fs.rmdirSync = original;
+ assert.strictEqual(rmdirSyncOptionsFromRimraf.recursive, undefined);
+}