Skip to content

Commit becbd85

Browse files
test: publicPath logs (#2912)
1 parent f7724ce commit becbd85

File tree

4 files changed

+70
-35
lines changed

4 files changed

+70
-35
lines changed

bin/cli-flags.js

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,48 @@ const BASIC_GROUP = 'Basic options:';
1010
module.exports = {
1111
devServer: [
1212
{
13-
name: 'bonjour',
14-
type: Boolean,
15-
describe: 'Broadcasts the server via ZeroConf networking on start',
13+
name: 'host',
14+
type: String,
15+
describe: 'The hostname/ip address the server will bind to',
16+
group: CONNECTION_GROUP,
17+
},
18+
{
19+
name: 'port',
20+
type: Number,
21+
describe: 'The port',
22+
group: CONNECTION_GROUP,
23+
},
24+
{
25+
name: 'static',
26+
type: [String, Boolean],
27+
describe: 'A directory to serve static content from.',
28+
group: RESPONSE_GROUP,
29+
multiple: true,
30+
negative: true,
1631
},
1732
{
1833
name: 'live-reload',
1934
type: Boolean,
2035
describe: 'Enables/Disables live reloading on changing files',
2136
negative: true,
2237
},
38+
{
39+
name: 'https',
40+
type: Boolean,
41+
group: SSL_GROUP,
42+
describe: 'HTTPS',
43+
},
44+
{
45+
name: 'http2',
46+
type: Boolean,
47+
group: SSL_GROUP,
48+
describe: 'HTTP/2, must be used with HTTPS',
49+
},
50+
{
51+
name: 'bonjour',
52+
type: Boolean,
53+
describe: 'Broadcasts the server via ZeroConf networking on start',
54+
},
2355
{
2456
name: 'client-progress',
2557
type: Boolean,
@@ -83,26 +115,6 @@ module.exports = {
83115
delete opts.clientLogging;
84116
},
85117
},
86-
{
87-
name: 'https',
88-
type: Boolean,
89-
group: SSL_GROUP,
90-
describe: 'HTTPS',
91-
},
92-
{
93-
name: 'http2',
94-
type: Boolean,
95-
group: SSL_GROUP,
96-
describe: 'HTTP/2, must be used with HTTPS',
97-
},
98-
{
99-
name: 'static',
100-
type: [String, Boolean],
101-
describe: 'A directory to serve static content from.',
102-
group: RESPONSE_GROUP,
103-
multiple: true,
104-
negative: true,
105-
},
106118
{
107119
name: 'history-api-fallback',
108120
type: Boolean,
@@ -115,24 +127,12 @@ module.exports = {
115127
describe: 'Enable gzip compression',
116128
group: RESPONSE_GROUP,
117129
},
118-
{
119-
name: 'port',
120-
type: Number,
121-
describe: 'The port',
122-
group: CONNECTION_GROUP,
123-
},
124130
{
125131
name: 'public',
126132
type: String,
127133
describe: 'The public hostname/ip address of the server',
128134
group: CONNECTION_GROUP,
129135
},
130-
{
131-
name: 'host',
132-
type: String,
133-
describe: 'The hostname/ip address the server will bind to',
134-
group: CONNECTION_GROUP,
135-
},
136136
{
137137
name: 'firewall',
138138
type: String,

test/cli/cli.test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,25 @@ runCLITest('CLI', () => {
175175
.catch(done);
176176
});
177177

178+
it('should log public path', (done) => {
179+
testBin(
180+
false,
181+
resolve(__dirname, '../fixtures/dev-public-path/webpack.config.js')
182+
)
183+
.then((output) => {
184+
expect(output.exitCode).toEqual(0);
185+
done();
186+
})
187+
.catch((err) => {
188+
// for windows
189+
expect(err.stderr).toContain(
190+
"webpack output is served from '/foo/bar' URL"
191+
);
192+
expect(err.stderr).toContain('Compiled successfully.');
193+
done();
194+
});
195+
});
196+
178197
it('should accept the promise function of webpack.config.js', (done) => {
179198
testBin(
180199
false,

test/fixtures/dev-public-path/foo.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
'use strict';
2+
3+
console.log('i am foo!');
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict';
2+
3+
const { join } = require('path');
4+
5+
module.exports = {
6+
mode: 'development',
7+
entry: join(__dirname, 'foo.js'),
8+
devServer: {
9+
dev: {
10+
publicPath: '/foo/bar',
11+
},
12+
},
13+
};

0 commit comments

Comments
 (0)