refactor(compiler-cli): expose `loadTestDirectory()` test helper (#36843)

This helper can be useful in other packages to load files from the
real disk into a mock file system.

PR Close #36843
This commit is contained in:
Pete Bacon Darwin 2020-04-28 20:59:09 +01:00 committed by Misko Hevery
parent 5d12c19ce9
commit dbf1f6b233
2 changed files with 3 additions and 1 deletions

View File

@ -8,6 +8,7 @@ ts_library(
srcs = glob([
"**/*.ts",
]),
module_name = "@angular/compiler-cli/test/helpers",
deps = [
"//packages:types",
"//packages/compiler-cli/src/ngtsc/file_system",

View File

@ -66,7 +66,8 @@ export function loadFakeCore(fs: FileSystem, basePath: string = '/') {
* @param directoryPath the path to the directory we want to load.
* @param mockPath the path within the mock file-system where the directory is to be loaded.
*/
function loadTestDirectory(fs: FileSystem, directoryPath: string, mockPath: AbsoluteFsPath): void {
export function loadTestDirectory(
fs: FileSystem, directoryPath: string, mockPath: AbsoluteFsPath): void {
readdirSync(directoryPath).forEach(item => {
const srcPath = resolve(directoryPath, item);
const targetPath = fs.resolve(mockPath, item);