Skip to content

Commit

Permalink
feat(build): add --poll option to build/serve/test commands
Browse files Browse the repository at this point in the history
Close #4268
Close #4715
  • Loading branch information
Charles Lyding authored and filipesilva committed Feb 16, 2017
1 parent 501267b commit 57ef508
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 6 deletions.
2 changes: 2 additions & 0 deletions docs/documentation/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,5 @@ or `ng serve --prod` will also make use of uglifying and tree-shaking functional
`--output-hashing` define the output filename cache-busting hashing mode

`--stats-json` generates a `stats.json` file which can be analyzed using tools such as: `webpack-bundle-analyzer` or https://webpack.github.io/analyse

`--poll` enable and define the file watching poll time period (milliseconds)
2 changes: 2 additions & 0 deletions docs/documentation/serve.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,5 @@
`--extract-css` (`-ec`) extract css from global styles onto css files instead of js ones

`--output-hashing` define the output filename cache-busting hashing mode

`--poll` enable and define the file watching poll time period (milliseconds)
2 changes: 2 additions & 0 deletions docs/documentation/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ You can run tests with coverage via `--code-coverage`. The coverage report will
`--reporters` list of reporters to use

`--build` flag to build prior to running tests

`--poll` enable and define the file watching poll time period (milliseconds)
10 changes: 10 additions & 0 deletions packages/@angular/cli/commands/build.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { CliConfig } from '../models/config';
import { BuildOptions } from '../models/build-options';
import { Version } from '../upgrade/version';

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

const config = CliConfig.fromProject() || CliConfig.fromGlobal();
const pollDefault = config.config.defaults && config.config.defaults.poll;

// defaults for BuildOptions
export const baseBuildCommandOptions: any = [
{
Expand Down Expand Up @@ -32,6 +36,12 @@ export const baseBuildCommandOptions: any = [
aliases: ['oh']
},
{ name: 'stats-json', type: Boolean, default: false },
{
name: 'poll',
type: Number,
default: pollDefault,
description: 'enable and define the file watching poll time period (milliseconds)'
}
];

export interface BuildTaskOptions extends BuildOptions {
Expand Down
12 changes: 11 additions & 1 deletion packages/@angular/cli/commands/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ const EmberTestCommand = require('../ember-cli/lib/commands/test');
import TestTask from '../tasks/test';
import {CliConfig} from '../models/config';

const config = CliConfig.fromProject() || CliConfig.fromGlobal();
const pollDefault = config.config.defaults && config.config.defaults.poll;

export interface TestOptions {
watch?: boolean;
codeCoverage?: boolean;
Expand All @@ -15,6 +18,7 @@ export interface TestOptions {
sourcemap?: boolean;
progress?: boolean;
config: string;
poll?: number;
}


Expand All @@ -31,7 +35,13 @@ const TestCommand = EmberTestCommand.extend({
{ name: 'port', type: Number },
{ name: 'reporters', type: String },
{ name: 'build', type: Boolean, default: true },
{ name: 'sourcemap', type: Boolean, default: true, aliases: ['sm'] }
{ name: 'sourcemap', type: Boolean, default: true, aliases: ['sm'] },
{
name: 'poll',
type: Number,
default: pollDefault,
description: 'enable and define the file watching poll time period (milliseconds)'
}
],

run: function(commandOptions: TestOptions) {
Expand Down
1 change: 1 addition & 0 deletions packages/@angular/cli/models/build-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ export interface BuildOptions {
locale?: string;
extractCss?: boolean;
outputHashing?: string;
poll?: number;
}
3 changes: 1 addition & 2 deletions packages/@angular/cli/plugins/karma.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const path = require('path');
const fs = require('fs');

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

function isDirectory(path) {
try {
Expand Down Expand Up @@ -81,7 +80,7 @@ const init = (config) => {
chunkModules: false
},
watchOptions: {
poll: CliConfig.fromProject().config.defaults.poll
poll: config.angularCli.poll
}
};

Expand Down
2 changes: 1 addition & 1 deletion packages/@angular/cli/tasks/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default Task.extend({
};

if (runTaskOptions.watch) {
webpackCompiler.watch({}, callback);
webpackCompiler.watch({ poll: runTaskOptions.poll }, callback);
} else {
webpackCompiler.run(callback);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/@angular/cli/tasks/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export default Task.extend({
proxy: proxyConfig,
compress: serveTaskOptions.target === 'production',
watchOptions: {
poll: projectConfig.defaults && projectConfig.defaults.poll
poll: serveTaskOptions.poll
},
https: serveTaskOptions.ssl,
overlay: serveTaskOptions.target === 'development'
Expand Down
3 changes: 2 additions & 1 deletion packages/@angular/cli/tasks/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export default Task.extend({
karmaOptions.angularCli = {
codeCoverage: options.codeCoverage,
sourcemap: options.sourcemap,
progress: options.progress
progress: options.progress,
poll: options.poll
};

// Assign additional karmaConfig options to the local ngapp config
Expand Down

0 comments on commit 57ef508

Please sign in to comment.