From 81ed2dc851c460bd85765b6ca97575a6c6b8abb2 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Thu, 25 Feb 2021 17:52:10 +0530 Subject: [PATCH 1/2] feat: add more negative flags --- bin/cli-flags.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bin/cli-flags.js b/bin/cli-flags.js index fcb468e3a7..ba749c8060 100644 --- a/bin/cli-flags.js +++ b/bin/cli-flags.js @@ -30,11 +30,15 @@ module.exports = { name: 'https', type: Boolean, description: 'Use HTTPS protocol.', + negatedDescription: 'Do not use HTTPS protocol.', + negative: true, }, { name: 'http2', type: Boolean, description: 'Use HTTP/2, must be used with HTTPS.', + negatedDescription: 'Do not use HTTP/2.', + negative: true, }, { name: 'bonjour', @@ -105,11 +109,16 @@ module.exports = { name: 'history-api-fallback', type: Boolean, description: 'Fallback to /index.html for Single Page Applications.', + negatedDescription: + 'Do not fallback to /index.html for Single Page Applications.', + negative: true, }, { name: 'compress', type: Boolean, description: 'Enable gzip compression.', + negatedDescription: 'Disable gzip compression.', + negative: true, }, { name: 'public', From cd58e7051648b2aa244b791c2b28b63e31c3e222 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 8 Mar 2021 19:17:41 +0530 Subject: [PATCH 2/2] test: add tests --- test/cli/cli.test.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/cli/cli.test.js b/test/cli/cli.test.js index 84bbd9324d..dcff4038f0 100644 --- a/test/cli/cli.test.js +++ b/test/cli/cli.test.js @@ -57,6 +57,17 @@ describe('CLI', () => { .catch(done); }); + it('--no-https', (done) => { + testBin('--no-https') + .then((output) => { + expect(output.exitCode).toEqual(0); + expect(/https:\/\//.test(output.stderr)).toEqual(false); + expect(/http:\/\/localhost:[0-9]+/.test(output.stderr)).toEqual(true); + done(); + }) + .catch(done); + }); + it('--history-api-fallback', (done) => { testBin('--history-api-fallback --no-color') .then((output) => { @@ -67,6 +78,18 @@ describe('CLI', () => { .catch(done); }); + it('--no-history-api-fallback', (done) => { + testBin('--no-history-api-fallback') + .then((output) => { + expect(output.exitCode).toEqual(0); + expect(output.stderr).not.toContain( + `404s will fallback to '/index.html'` + ); + done(); + }) + .catch(done); + }); + it('unspecified host and port', (done) => { testBin('') .then((output) => {