From ebc966f398c38c23c6d36b4be47f303ddfd29e7d Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Tue, 9 Mar 2021 18:05:41 +0530 Subject: [PATCH] feat: add more negative flags - `--no-https`, `--no-http2`, `--no-compress` and `--no-history-api-fallback` (#3070) --- bin/cli-flags.js | 9 +++++++++ test/cli/cli.test.js | 23 +++++++++++++++++++++++ 2 files changed, 32 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', 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) => {