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) => {