Skip to content

Commit 49e8eee

Browse files
clydinfilipesilva
authored andcommitted
feat(@angular-devkit/build-angular): allow optional karma watch
Fixes angular#847
1 parent 51c6129 commit 49e8eee

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

packages/angular_devkit/build_angular/src/angular-cli-files/plugins/karma.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ const init: any = (config: any, emitter: any, customFileHandlers: any) => {
113113
delete webpackConfig.entry.styles;
114114

115115
// The webpack tier owns the watch behavior so we want to force it in the config.
116-
webpackConfig.watch = options.watch;
117-
if (!options.watch) {
116+
webpackConfig.watch = !config.singleRun;
117+
if (config.singleRun) {
118118
// There's no option to turn off file watching in webpack-dev-server, but
119119
// we can override the file watcher instead.
120120
webpackConfig.plugins.unshift({

packages/angular_devkit/build_angular/src/karma/index.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,11 @@ export class KarmaBuilder implements Builder<KarmaBuilderSchema> {
5959
// TODO: adjust options to account for not passing them blindly to karma.
6060
// const karmaOptions: any = Object.assign({}, options);
6161
// tslint:disable-next-line:no-any
62-
const karmaOptions: any = {
63-
singleRun: !options.watch,
64-
};
62+
const karmaOptions: any = {};
63+
64+
if (options.watch !== undefined) {
65+
karmaOptions.singleRun = !options.watch;
66+
}
6567

6668
// Convert browsers from a string to an array
6769
if (options.browsers) {

packages/angular_devkit/build_angular/src/karma/schema.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@
7474
},
7575
"watch": {
7676
"type": "boolean",
77-
"description": "Run build when files change.",
78-
"default": false
77+
"description": "Run build when files change."
7978
},
8079
"poll": {
8180
"type": "number",

0 commit comments

Comments
 (0)