refactor(compiler-cli): return the `FileSystem` from `initMockFileSystem()` (#39617)

It is common to want to use the file system once it is initialized,
so it makes sense for this function to return it.

PR Close #39617
This commit is contained in:
Pete Bacon Darwin 2020-11-11 15:29:42 +00:00 committed by atscott
parent 9e53c6ee40
commit 7b6ea973f6
1 changed files with 2 additions and 1 deletions

View File

@ -66,10 +66,11 @@ runInEachFileSystem.unix = (callback: (os: string) => void) =>
runInEachFileSystem.windows = (callback: (os: string) => void) => runInEachFileSystem.windows = (callback: (os: string) => void) =>
runInFileSystem(FS_WINDOWS, callback, true); runInFileSystem(FS_WINDOWS, callback, true);
export function initMockFileSystem(os: string, cwd?: AbsoluteFsPath): void { export function initMockFileSystem(os: string, cwd?: AbsoluteFsPath): MockFileSystem {
const fs = createMockFileSystem(os, cwd); const fs = createMockFileSystem(os, cwd);
setFileSystem(fs); setFileSystem(fs);
monkeyPatchTypeScript(os, fs); monkeyPatchTypeScript(os, fs);
return fs;
} }
function createMockFileSystem(os: string, cwd?: AbsoluteFsPath): MockFileSystem { function createMockFileSystem(os: string, cwd?: AbsoluteFsPath): MockFileSystem {