From e8670648588536972b8516d2f9b6b0c54d161703 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Sat, 31 Aug 2019 16:48:15 +0530 Subject: [PATCH 1/7] feat: add status log when quiet --- lib/utils/status.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/utils/status.js b/lib/utils/status.js index 2a8ba63f91..9a7d641155 100644 --- a/lib/utils/status.js +++ b/lib/utils/status.js @@ -1,10 +1,19 @@ '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) { + log = log({ + name: 'wds', + logger, + timestamp: options.logTime, + }); + } + const contentBase = Array.isArray(options.contentBase) ? options.contentBase.join(', ') : options.contentBase; From 58d8a9a4a9b879e5bf69a2149e264f057a9de623 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Sat, 31 Aug 2019 16:57:03 +0530 Subject: [PATCH 2/7] chore: update function call --- lib/utils/status.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utils/status.js b/lib/utils/status.js index 9a7d641155..ecd11233ce 100644 --- a/lib/utils/status.js +++ b/lib/utils/status.js @@ -7,7 +7,7 @@ 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) { - log = log({ + log = logger({ name: 'wds', logger, timestamp: options.logTime, From 75dc99eff8e60333964604237a6dfc82ea75360a Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Sat, 31 Aug 2019 17:00:59 +0530 Subject: [PATCH 3/7] chore: add comment for the behaviour --- lib/utils/status.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/utils/status.js b/lib/utils/status.js index ecd11233ce..bb699291ad 100644 --- a/lib/utils/status.js +++ b/lib/utils/status.js @@ -7,6 +7,7 @@ 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', logger, From 3119a120d2294f38355c6bf12dd38e97b6c1bbc0 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Sat, 31 Aug 2019 17:05:31 +0530 Subject: [PATCH 4/7] chore: fix lint --- lib/utils/status.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utils/status.js b/lib/utils/status.js index bb699291ad..f0075c33ae 100644 --- a/lib/utils/status.js +++ b/lib/utils/status.js @@ -1,6 +1,6 @@ 'use strict'; -const logger = require("webpack-log"); +const logger = require('webpack-log'); const colors = require('./colors'); const runOpen = require('./runOpen'); From 80a7fa42bb98dbf2455e5656c901ee95705acdf6 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Sat, 31 Aug 2019 17:22:11 +0530 Subject: [PATCH 5/7] chore: update level --- lib/utils/status.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utils/status.js b/lib/utils/status.js index f0075c33ae..1d2ed01bf4 100644 --- a/lib/utils/status.js +++ b/lib/utils/status.js @@ -10,7 +10,7 @@ function status(uri, options, log, useColor) { // Add temporary logger to output just the status of the dev server log = logger({ name: 'wds', - logger, + level: 'info', timestamp: options.logTime, }); } From 6c60d8b92f765e67b9ed4747652ffe72ee23076e Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Wed, 4 Sep 2019 20:48:45 +0530 Subject: [PATCH 6/7] test: add quiet flag test --- test/cli/cli.test.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/cli/cli.test.js b/test/cli/cli.test.js index 372a21afef..ac5ef09f4d 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) => { From bd3e2c2e082c73099c96c43d1cbf177ba8178155 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Wed, 4 Sep 2019 20:52:42 +0530 Subject: [PATCH 7/7] chore: lint --- test/cli/cli.test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/cli/cli.test.js b/test/cli/cli.test.js index ac5ef09f4d..83d4989866 100644 --- a/test/cli/cli.test.js +++ b/test/cli/cli.test.js @@ -36,9 +36,9 @@ describe('CLI', () => { 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('webpack output is served from /')).toBe( + true + ); expect( output.stdout.includes('Content not from webpack is served from') ).toBe(true);