Skip to content

Commit af31f98

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 a334e4e commit af31f98

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
@@ -50,7 +50,7 @@ export function createMigrationCompilerHost(
5050
const treeRelativePath = relative(basePath, fileName);
5151
let result: string|undefined = fakeRead?.(treeRelativePath);
5252

53-
if (result === undefined) {
53+
if (typeof result !== 'string') {
5454
// If the relative path resolved to somewhere outside of the tree, fall back to
5555
// TypeScript's default file reading function since the `tree` will throw an error.
5656
result = treeRelativePath.startsWith('..') ? defaultReadFile.call(host, fileName) :
@@ -60,7 +60,7 @@ export function createMigrationCompilerHost(
6060
// Strip BOM as otherwise TSC methods (Ex: getWidth) will return an offset,
6161
// which breaks the CLI UpdateRecorder.
6262
// See: https://github.com/angular/angular/pull/30719
63-
return result ? result.replace(/^\uFEFF/, '') : undefined;
63+
return typeof result === 'string' ? result.replace(/^\uFEFF/, '') : undefined;
6464
};
6565

6666
return host;

0 commit comments

Comments
 (0)