Skip to content

Commit 8d99355

Browse files
clydinhybrist
authored andcommitted
refactor(@angular-devkit/build-angular): remove redundant isFirstRun check in Karma plugin
The Promise resolve function is idempotent. Removing the explicit 'isFirstRun' check simplifies the code as subsequent calls to resolve() after the first compilation will be ignored by the Promise.
1 parent fb8d689 commit 8d99355

File tree

1 file changed

+5
-9
lines changed
  • packages/angular_devkit/build_angular/src/tools/webpack/plugins/karma

1 file changed

+5
-9
lines changed

packages/angular_devkit/build_angular/src/tools/webpack/plugins/karma/karma.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ const init: any = (config: any, emitter: any) => {
8585
});
8686

8787
let lastCompilationHash: string | undefined;
88-
let isFirstRun = true;
8988

9089
return new Promise<void>((resolve) => {
9190
compiler.hooks.done.tap('karma', (stats) => {
@@ -115,14 +114,11 @@ const init: any = (config: any, emitter: any) => {
115114
emitter.refreshFiles();
116115
}
117116

118-
if (isFirstRun) {
119-
// This is needed to block Karma from launching browsers before Webpack writes the assets in memory.
120-
// See the below:
121-
// https://github.com/karma-runner/karma-chrome-launcher/issues/154#issuecomment-986661937
122-
// https://github.com/angular/angular-cli/issues/22495
123-
isFirstRun = false;
124-
resolve();
125-
}
117+
// This is needed to block Karma from launching browsers before Webpack writes the assets in memory.
118+
// See the below:
119+
// https://github.com/karma-runner/karma-chrome-launcher/issues/154#issuecomment-986661937
120+
// https://github.com/angular/angular-cli/issues/22495
121+
resolve();
126122
});
127123
});
128124
};

0 commit comments

Comments
 (0)