Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

rmdirSync doesn't throw on non-empty directory #61

Open
DanielSWolf opened this issue Aug 7, 2018 · 0 comments
Open

rmdirSync doesn't throw on non-empty directory #61

DanielSWolf opened this issue Aug 7, 2018 · 0 comments

Comments

@DanielSWolf
Copy link

The original Node implementation of rmdirSync throws an error if the directory is not empty. The implementation in memory-fs quietly deletes the directory an all its contents. rmdirSync effectively behaves like rmdirpSync should.

This is a problem when using memory-fs to mock the native file system and trusting that it behaves similarly.

const MemoryFileSystem = require('memory-fs');

const fs = new MemoryFileSystem();
fs.mkdirpSync('/a/b/c');
fs.rmdirSync('/a/b'); // This should fail. b is not empty.
console.log(fs.readdirSync('/a')); // Empty
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant