Skip to content

Commit 04e0ac3

Browse files
crisbetothePunderWoman
authored andcommitted
fix(migrations): migration host incorrectly reading empty files (#48849)
Fixes that the migration host was doing a basic falsy check if the content was read correctly which meant that a component with an empty template would be considered as having a missing template file. Fixes #48846. PR Close #48849
1 parent 65c74ed commit 04e0ac3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/core/schematics/utils/typescript/compiler_host.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function createMigrationCompilerHost(
6666
const treeRelativePath = relative(basePath, fileName);
6767
let result: string|undefined = fakeRead?.(treeRelativePath);
6868

69-
if (result === undefined) {
69+
if (typeof result !== 'string') {
7070
// If the relative path resolved to somewhere outside of the tree, fall back to
7171
// TypeScript's default file reading function since the `tree` will throw an error.
7272
result = treeRelativePath.startsWith('..') ? defaultReadFile.call(host, fileName) :
@@ -76,7 +76,7 @@ function createMigrationCompilerHost(
7676
// Strip BOM as otherwise TSC methods (Ex: getWidth) will return an offset,
7777
// which breaks the CLI UpdateRecorder.
7878
// See: https://github.com/angular/angular/pull/30719
79-
return result ? result.replace(/^\uFEFF/, '') : undefined;
79+
return typeof result === 'string' ? result.replace(/^\uFEFF/, '') : undefined;
8080
};
8181

8282
return host;

0 commit comments

Comments
 (0)