Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/angular_devkit/core/src/virtual-fs/host/memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export class SimpleMemoryHost implements Host<{}> {
path = this._toAbsolute(path);
if (this._isDirectory(path)) {
for (const [cachePath] of this._cache.entries()) {
if (path.startsWith(cachePath + NormalizedSep)) {
if (cachePath.startsWith(path + NormalizedSep) || cachePath === path) {
this._cache.delete(cachePath);
}
}
Expand Down
16 changes: 16 additions & 0 deletions packages/angular_devkit/core/src/virtual-fs/host/memory_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,22 @@ describe('SimpleMemoryHost', () => {
expect(host.exists(normalize('/sub/file1'))).toBe(false);
});

it('can delete directory', () => {
const host = new SyncDelegateHost(new SimpleMemoryHost());

const buffer = stringToFileBuffer('hello');

expect(host.exists(normalize('/sub/file1'))).toBe(false);
host.write(normalize('/sub/file1'), buffer);
host.write(normalize('/subfile.2'), buffer);
expect(host.exists(normalize('/sub/file1'))).toBe(true);
expect(host.exists(normalize('/subfile.2'))).toBe(true);
host.delete(normalize('/sub'));
expect(host.exists(normalize('/sub/file1'))).toBe(false);
expect(host.exists(normalize('/sub'))).toBe(false);
expect(host.exists(normalize('/subfile.2'))).toBe(true);
});

it('can rename', () => {
const host = new SyncDelegateHost(new SimpleMemoryHost());

Expand Down