Skip to content

Commit 57ef508

Browse files
Charles Lydingfilipesilva
Charles Lyding
authored andcommitted
feat(build): add --poll option to build/serve/test commands
Close #4268 Close #4715
1 parent 501267b commit 57ef508

File tree

10 files changed

+33
-6
lines changed

10 files changed

+33
-6
lines changed

docs/documentation/build.md

+2
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,5 @@ or `ng serve --prod` will also make use of uglifying and tree-shaking functional
9696
`--output-hashing` define the output filename cache-busting hashing mode
9797

9898
`--stats-json` generates a `stats.json` file which can be analyzed using tools such as: `webpack-bundle-analyzer` or https://webpack.github.io/analyse
99+
100+
`--poll` enable and define the file watching poll time period (milliseconds)

docs/documentation/serve.md

+2
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,5 @@
5959
`--extract-css` (`-ec`) extract css from global styles onto css files instead of js ones
6060

6161
`--output-hashing` define the output filename cache-busting hashing mode
62+
63+
`--poll` enable and define the file watching poll time period (milliseconds)

docs/documentation/test.md

+2
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,5 @@ You can run tests with coverage via `--code-coverage`. The coverage report will
2929
`--reporters` list of reporters to use
3030

3131
`--build` flag to build prior to running tests
32+
33+
`--poll` enable and define the file watching poll time period (milliseconds)

packages/@angular/cli/commands/build.ts

+10
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
import { CliConfig } from '../models/config';
12
import { BuildOptions } from '../models/build-options';
23
import { Version } from '../upgrade/version';
34

45
const Command = require('../ember-cli/lib/models/command');
56

7+
const config = CliConfig.fromProject() || CliConfig.fromGlobal();
8+
const pollDefault = config.config.defaults && config.config.defaults.poll;
9+
610
// defaults for BuildOptions
711
export const baseBuildCommandOptions: any = [
812
{
@@ -32,6 +36,12 @@ export const baseBuildCommandOptions: any = [
3236
aliases: ['oh']
3337
},
3438
{ name: 'stats-json', type: Boolean, default: false },
39+
{
40+
name: 'poll',
41+
type: Number,
42+
default: pollDefault,
43+
description: 'enable and define the file watching poll time period (milliseconds)'
44+
}
3545
];
3646

3747
export interface BuildTaskOptions extends BuildOptions {

packages/@angular/cli/commands/test.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ const EmberTestCommand = require('../ember-cli/lib/commands/test');
22
import TestTask from '../tasks/test';
33
import {CliConfig} from '../models/config';
44

5+
const config = CliConfig.fromProject() || CliConfig.fromGlobal();
6+
const pollDefault = config.config.defaults && config.config.defaults.poll;
7+
58
export interface TestOptions {
69
watch?: boolean;
710
codeCoverage?: boolean;
@@ -15,6 +18,7 @@ export interface TestOptions {
1518
sourcemap?: boolean;
1619
progress?: boolean;
1720
config: string;
21+
poll?: number;
1822
}
1923

2024

@@ -31,7 +35,13 @@ const TestCommand = EmberTestCommand.extend({
3135
{ name: 'port', type: Number },
3236
{ name: 'reporters', type: String },
3337
{ name: 'build', type: Boolean, default: true },
34-
{ name: 'sourcemap', type: Boolean, default: true, aliases: ['sm'] }
38+
{ name: 'sourcemap', type: Boolean, default: true, aliases: ['sm'] },
39+
{
40+
name: 'poll',
41+
type: Number,
42+
default: pollDefault,
43+
description: 'enable and define the file watching poll time period (milliseconds)'
44+
}
3545
],
3646

3747
run: function(commandOptions: TestOptions) {

packages/@angular/cli/models/build-options.ts

+1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ export interface BuildOptions {
1414
locale?: string;
1515
extractCss?: boolean;
1616
outputHashing?: string;
17+
poll?: number;
1718
}

packages/@angular/cli/plugins/karma.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ const path = require('path');
22
const fs = require('fs');
33

44
const getTestConfig = require('../models/webpack-configs/test').getTestConfig;
5-
const CliConfig = require('../models/config').CliConfig;
65

76
function isDirectory(path) {
87
try {
@@ -81,7 +80,7 @@ const init = (config) => {
8180
chunkModules: false
8281
},
8382
watchOptions: {
84-
poll: CliConfig.fromProject().config.defaults.poll
83+
poll: config.angularCli.poll
8584
}
8685
};
8786

packages/@angular/cli/tasks/build.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export default Task.extend({
5454
};
5555

5656
if (runTaskOptions.watch) {
57-
webpackCompiler.watch({}, callback);
57+
webpackCompiler.watch({ poll: runTaskOptions.poll }, callback);
5858
} else {
5959
webpackCompiler.run(callback);
6060
}

packages/@angular/cli/tasks/serve.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export default Task.extend({
109109
proxy: proxyConfig,
110110
compress: serveTaskOptions.target === 'production',
111111
watchOptions: {
112-
poll: projectConfig.defaults && projectConfig.defaults.poll
112+
poll: serveTaskOptions.poll
113113
},
114114
https: serveTaskOptions.ssl,
115115
overlay: serveTaskOptions.target === 'development'

packages/@angular/cli/tasks/test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ export default Task.extend({
2121
karmaOptions.angularCli = {
2222
codeCoverage: options.codeCoverage,
2323
sourcemap: options.sourcemap,
24-
progress: options.progress
24+
progress: options.progress,
25+
poll: options.poll
2526
};
2627

2728
// Assign additional karmaConfig options to the local ngapp config

0 commit comments

Comments
 (0)