refactor(ivy): add removeFile to ngtsc FileSystem (#34722)

PR Close #34722
This commit is contained in:
Pete Bacon Darwin
2020-01-09 22:34:28 +00:00
committed by Andrew Kushnir
parent 92c411f86d
commit ecbc25044c
7 changed files with 49 additions and 3 deletions

View File

@ -44,6 +44,20 @@ export abstract class MockFileSystem implements FileSystem {
entity[basename] = data;
}
removeFile(path: AbsoluteFsPath): void {
const [folderPath, basename] = this.splitIntoFolderAndFile(path);
const {entity} = this.findFromPath(folderPath);
if (entity === null || !isFolder(entity)) {
throw new MockFileSystemError(
'ENOENT', path, `Unable to remove file "${path}". The containing folder does not exist.`);
}
if (isFolder(entity[basename])) {
throw new MockFileSystemError(
'EISDIR', path, `Unable to remove file "${path}". The path to remove is a folder.`);
}
delete entity[basename];
}
symlink(target: AbsoluteFsPath, path: AbsoluteFsPath): void {
const [folderPath, basename] = this.splitIntoFolderAndFile(path);
const {entity} = this.findFromPath(folderPath);