Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(rmdir): proper async functionality
  • Loading branch information
imsnif committed Dec 25, 2019
1 parent 1e943ae commit cc75c56
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/__tests__/volume.test.ts
Expand Up @@ -958,11 +958,19 @@ describe('volume', () => {
const vol = new Volume();
vol.mkdirSync('/dir1/dir2/dir3', { recursive: true });
vol.rmdirSync('/dir1', { recursive: true });
expect(!!vol.root.getChild('/dir1')).toBe(false);
expect(!!vol.root.getChild('dir1')).toBe(false);
});
});
describe('.rmdir(path, callback)', () => {
xit('Remove single dir', () => {});
it('Async remove dir /dir1/dir2/dir3 recursively', done => {
const vol = new Volume();
vol.mkdirSync('/dir1/dir2/dir3', { recursive: true });
vol.rmdir('/dir1', { recursive: true }, () => {
expect(!!vol.root.getChild('dir1')).toBe(false);
done();
});
});
});
describe('.watchFile(path[, options], listener)', () => {
it('Calls listener on .writeFile', done => {
Expand Down
2 changes: 1 addition & 1 deletion src/volume.ts
Expand Up @@ -1931,7 +1931,7 @@ export class Volume {
rmdir(path: TFilePath, a: TCallback<void> | IRmdirOptions, b?: TCallback<void>) {
const opts: IRmdirOptions = getRmdirOptions(a);
const callback: TCallback<void> = validateCallback(typeof a === 'function' ? a : b);
this.wrapAsync(this.rmdirBase, [pathToFilename(path)], callback);
this.wrapAsync(this.rmdirBase, [pathToFilename(path), opts], callback);
}

private fchmodBase(fd: number, modeNum: number) {
Expand Down

0 comments on commit cc75c56

Please sign in to comment.