Skip to content

Commit 7e2224e

Browse files
rishabh3112evilebottnawi
authored andcommitted
fix: add status in quiet log level (#2235)
1 parent 3748c3f commit 7e2224e

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

lib/utils/status.js

+10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
'use strict';
22

3+
const logger = require('webpack-log');
34
const colors = require('./colors');
45
const runOpen = require('./runOpen');
56

67
// TODO: don't emit logs when webpack-dev-server is used via Node.js API
78
function status(uri, options, log, useColor) {
9+
if (options.quiet === true) {
10+
// Add temporary logger to output just the status of the dev server
11+
log = logger({
12+
name: 'wds',
13+
level: 'info',
14+
timestamp: options.logTime,
15+
});
16+
}
17+
818
const contentBase = Array.isArray(options.contentBase)
919
? options.contentBase.join(', ')
1020
: options.contentBase;

test/cli/cli.test.js

+16
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,22 @@ describe('CLI', () => {
2929
.catch(done);
3030
});
3131

32+
it('--quiet', async (done) => {
33+
const output = await testBin('--quiet');
34+
expect(output.code).toEqual(0);
35+
expect(output.stdout.split('\n').length === 3).toBe(true);
36+
expect(
37+
output.stdout.includes('Project is running at http://localhost:8080/')
38+
).toBe(true);
39+
expect(output.stdout.includes('webpack output is served from /')).toBe(
40+
true
41+
);
42+
expect(
43+
output.stdout.includes('Content not from webpack is served from')
44+
).toBe(true);
45+
done();
46+
});
47+
3248
it('--progress --profile', (done) => {
3349
testBin('--progress --profile')
3450
.then((output) => {

0 commit comments

Comments
 (0)