Skip to content

Commit

Permalink
fix: add status in quiet log level (#2235)
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabh3112 authored and evilebottnawi committed Sep 12, 2019
1 parent 3748c3f commit 7e2224e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/utils/status.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
'use strict';

const logger = require('webpack-log');
const colors = require('./colors');
const runOpen = require('./runOpen');

// TODO: don't emit logs when webpack-dev-server is used via Node.js API
function status(uri, options, log, useColor) {
if (options.quiet === true) {
// Add temporary logger to output just the status of the dev server
log = logger({
name: 'wds',
level: 'info',
timestamp: options.logTime,
});
}

const contentBase = Array.isArray(options.contentBase)
? options.contentBase.join(', ')
: options.contentBase;
Expand Down
16 changes: 16 additions & 0 deletions test/cli/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@ describe('CLI', () => {
.catch(done);
});

it('--quiet', async (done) => {
const output = await testBin('--quiet');
expect(output.code).toEqual(0);
expect(output.stdout.split('\n').length === 3).toBe(true);
expect(
output.stdout.includes('Project is running at http://localhost:8080/')
).toBe(true);
expect(output.stdout.includes('webpack output is served from /')).toBe(
true
);
expect(
output.stdout.includes('Content not from webpack is served from')
).toBe(true);
done();
});

it('--progress --profile', (done) => {
testBin('--progress --profile')
.then((output) => {
Expand Down

0 comments on commit 7e2224e

Please sign in to comment.