Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

Commit 47f43f2

Browse files
committed
refactor(templates): don't try to replace templates on .module.ts files
1 parent 68fc463 commit 47f43f2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/template.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { readFileSync, writeFileSync } from 'fs';
22
import { dirname, extname, join, parse, resolve } from 'path';
33

4+
import * as Constants from './util/constants';
45
import { BuildContext, BuildState, ChangedFile, File } from './util/interfaces';
5-
import { changeExtension } from './util/helpers';
6+
import { changeExtension, getStringPropertyValue } from './util/helpers';
67
import { Logger } from './logger/logger';
78
import { invalidateCache } from './rollup';
89

@@ -59,7 +60,8 @@ export function templateUpdate(changedFiles: ChangedFile[], context: BuildContex
5960
}
6061

6162
function updateCorrespondingJsFile(context: BuildContext, newTemplateContent: string, existingHtmlTemplatePath: string) {
62-
const javascriptFiles = context.fileCache.getAll().filter((file: File) => dirname(file.path) === dirname(existingHtmlTemplatePath) && extname(file.path) === '.js');
63+
const moduleFileExtension = changeExtension(getStringPropertyValue(Constants.ENV_NG_MODULE_FILE_NAME_SUFFIX), '.js');
64+
const javascriptFiles = context.fileCache.getAll().filter((file: File) => dirname(file.path) === dirname(existingHtmlTemplatePath) && extname(file.path) === '.js' && !file.path.endsWith(moduleFileExtension));
6365
for (const javascriptFile of javascriptFiles) {
6466
const newContent = replaceExistingJsTemplate(javascriptFile.content, newTemplateContent, existingHtmlTemplatePath);
6567
if (newContent && newContent !== javascriptFile.content) {

0 commit comments

Comments
 (0)