refactor(compiler-cli): add removeDir() to FileSystem (#35079)

PR Close #35079
This commit is contained in:
Pete Bacon Darwin
2020-01-31 21:07:59 +00:00
committed by Misko Hevery
parent 16e15f50d2
commit 2e52fcf1eb
11 changed files with 59 additions and 0 deletions

View File

@ -131,6 +131,17 @@ export abstract class MockFileSystem implements FileSystem {
}
}
removeDeep(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 folder "${path}". The containing folder does not exist.`);
}
delete entity[basename];
}
isRoot(path: AbsoluteFsPath): boolean { return this.dirname(path) === path; }
extname(path: AbsoluteFsPath|PathSegment): string {