From 7e2224e51f8ffd2a1df12c2bdc035f29944ed04d Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Thu, 12 Sep 2019 22:51:13 +0530 Subject: [PATCH] fix: add status in quiet log level (#2235) --- lib/utils/status.js | 10 ++++++++++ test/cli/cli.test.js | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/lib/utils/status.js b/lib/utils/status.js index 2a8ba63f91..1d2ed01bf4 100644 --- a/lib/utils/status.js +++ b/lib/utils/status.js @@ -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; diff --git a/test/cli/cli.test.js b/test/cli/cli.test.js index 372a21afef..83d4989866 100644 --- a/test/cli/cli.test.js +++ b/test/cli/cli.test.js @@ -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) => {