Skip to content

Commit

Permalink
feat: add more negative flags - --no-https, --no-http2, `--no-com…
Browse files Browse the repository at this point in the history
…press` and `--no-history-api-fallback` (#3070)
  • Loading branch information
snitin315 committed Mar 9, 2021
1 parent fc3a8e6 commit ebc966f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
9 changes: 9 additions & 0 deletions bin/cli-flags.js
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
23 changes: 23 additions & 0 deletions test/cli/cli.test.js
Expand Up @@ -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) => {
Expand All @@ -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) => {
Expand Down

0 comments on commit ebc966f

Please sign in to comment.