Skip to content

Commit e15d9cd

Browse files
authored
fix(webpack-cli): verbose flag functionality (#1549)
1 parent 3f1d7c0 commit e15d9cd

File tree

5 files changed

+22
-7
lines changed

5 files changed

+22
-7
lines changed

packages/webpack-cli/lib/groups/StatsGroup.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,10 @@ class StatsGroup extends GroupHelper {
1515
resolveOptions() {
1616
if (this.args.verbose && this.args.stats) {
1717
logger.warn('Conflict between "verbose" and "stats" options. Using verbose.');
18-
this.opts.option.stats = {
19-
verbose: true,
20-
};
18+
this.opts.options.stats = 'verbose';
2119
} else {
2220
if (this.args.verbose) {
23-
this.opts.option.stats = {
24-
verbose: true,
25-
};
21+
this.opts.options.stats = 'verbose';
2622
} else if (!StatsGroup.validOptions().includes(this.args.stats)) {
2723
logger.warn(`'${this.args.stats}' is invalid value for stats. Using 'normal' option for stats`);
2824
this.opts.options.stats = 'normal';

packages/webpack-cli/lib/utils/cli-flags.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ module.exports = {
237237
name: 'stats',
238238
usage: '--stats verbose',
239239
type: String,
240-
defaultValue: 'normal',
241240
group: DISPLAY_GROUP,
242241
description: 'It instructs webpack on how to treat the stats',
243242
link: 'https://webpack.js.org/configuration/stats/#stats',

test/stats/stats.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ describe('stats flag', () => {
4545
expect(stdout).toBeTruthy();
4646
});
4747

48+
it('should warn when --verbose & --stats are passed together', () => {
49+
const { stderr, stdout } = run(__dirname, ['--verbose', '--stats', 'normal']);
50+
expect(stderr).toBeTruthy();
51+
expect(stderr).toContain('Conflict between "verbose" and "stats" options');
52+
expect(stdout).toBeTruthy();
53+
});
54+
4855
it('should warn when an unknown flag stats value is passed', () => {
4956
const { stderr, stdout } = run(__dirname, ['--stats', 'foo']);
5057
expect(stderr).toBeTruthy();

test/verbose/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('test');

test/verbose/verbose-flag.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict';
2+
// eslint-disable-next-line node/no-unpublished-require
3+
const { run } = require('../utils/test-utils');
4+
5+
describe('verbose flag', () => {
6+
it('should accept --verbose', () => {
7+
const { stderr, stdout } = run(__dirname, ['--verbose']);
8+
expect(stderr).toBeFalsy();
9+
expect(stdout).toBeTruthy();
10+
expect(stdout).toContain('LOG from webpack');
11+
});
12+
});

0 commit comments

Comments
 (0)