Skip to content

Commit f6f0c80

Browse files
committed
fix(@angular-devkit/core): ensure full path is renamed for memory host
1 parent 48780c5 commit f6f0c80

File tree

1 file changed

+18
-0
lines changed
  • packages/angular_devkit/core/src/virtual-fs/host

1 file changed

+18
-0
lines changed

packages/angular_devkit/core/src/virtual-fs/host/memory.ts

+18
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
Stats,
3434
} from './interface';
3535

36+
3637
export interface SimpleMemoryHostStats {
3738
readonly content: FileBuffer | null;
3839
}
@@ -210,6 +211,23 @@ export class SimpleMemoryHost implements Host<{}> {
210211
} else {
211212
const content = this._cache.get(from);
212213
if (content) {
214+
const fragments = split(to);
215+
const newDirectories = [];
216+
let curr: Path = normalize('/');
217+
for (const fr of fragments) {
218+
curr = join(curr, fr);
219+
const maybeStats = this._cache.get(fr);
220+
if (maybeStats) {
221+
if (maybeStats.isFile()) {
222+
throw new PathIsFileException(curr);
223+
}
224+
} else {
225+
newDirectories.push(curr);
226+
}
227+
}
228+
for (const newDirectory of newDirectories) {
229+
this._cache.set(newDirectory, this._newDirStats());
230+
}
213231
this._cache.delete(from);
214232
this._cache.set(to, content);
215233
}

0 commit comments

Comments
 (0)