Skip to content

Commit ebc966f

Browse files
authored
feat: add more negative flags - --no-https, --no-http2, --no-compress and --no-history-api-fallback (#3070)
1 parent fc3a8e6 commit ebc966f

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

bin/cli-flags.js

+9
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,15 @@ module.exports = {
3030
name: 'https',
3131
type: Boolean,
3232
description: 'Use HTTPS protocol.',
33+
negatedDescription: 'Do not use HTTPS protocol.',
34+
negative: true,
3335
},
3436
{
3537
name: 'http2',
3638
type: Boolean,
3739
description: 'Use HTTP/2, must be used with HTTPS.',
40+
negatedDescription: 'Do not use HTTP/2.',
41+
negative: true,
3842
},
3943
{
4044
name: 'bonjour',
@@ -105,11 +109,16 @@ module.exports = {
105109
name: 'history-api-fallback',
106110
type: Boolean,
107111
description: 'Fallback to /index.html for Single Page Applications.',
112+
negatedDescription:
113+
'Do not fallback to /index.html for Single Page Applications.',
114+
negative: true,
108115
},
109116
{
110117
name: 'compress',
111118
type: Boolean,
112119
description: 'Enable gzip compression.',
120+
negatedDescription: 'Disable gzip compression.',
121+
negative: true,
113122
},
114123
{
115124
name: 'public',

test/cli/cli.test.js

+23
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,17 @@ describe('CLI', () => {
5757
.catch(done);
5858
});
5959

60+
it('--no-https', (done) => {
61+
testBin('--no-https')
62+
.then((output) => {
63+
expect(output.exitCode).toEqual(0);
64+
expect(/https:\/\//.test(output.stderr)).toEqual(false);
65+
expect(/http:\/\/localhost:[0-9]+/.test(output.stderr)).toEqual(true);
66+
done();
67+
})
68+
.catch(done);
69+
});
70+
6071
it('--history-api-fallback', (done) => {
6172
testBin('--history-api-fallback --no-color')
6273
.then((output) => {
@@ -67,6 +78,18 @@ describe('CLI', () => {
6778
.catch(done);
6879
});
6980

81+
it('--no-history-api-fallback', (done) => {
82+
testBin('--no-history-api-fallback')
83+
.then((output) => {
84+
expect(output.exitCode).toEqual(0);
85+
expect(output.stderr).not.toContain(
86+
`404s will fallback to '/index.html'`
87+
);
88+
done();
89+
})
90+
.catch(done);
91+
});
92+
7093
it('unspecified host and port', (done) => {
7194
testBin('')
7295
.then((output) => {

0 commit comments

Comments
 (0)