Skip to content

Commit df0384e

Browse files
author
John Chipps-Harding
committed
fix: runOpen - made warning output related url
1 parent c727994 commit df0384e

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

lib/utils/runOpen.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ const isAbsoluteUrl = require('is-absolute-url');
66
function runOpen(uri, options, log) {
77
// https://github.com/webpack/webpack-dev-server/issues/1990
88
let openOptions = { wait: false };
9-
let openMessage = 'Unable to open browser';
9+
let openOptionValue = '';
1010

1111
if (typeof options.open === 'string') {
1212
openOptions = Object.assign({}, openOptions, { app: options.open });
13-
openMessage += `: ${options.open}`;
13+
openOptionValue = `: ${options.open}`;
1414
}
1515

1616
const pages =
@@ -24,7 +24,7 @@ function runOpen(uri, options, log) {
2424

2525
return open(pageUrl, openOptions).catch(() => {
2626
log.warn(
27-
`${openMessage}. If you are running in a headless environment, please do not use the --open flag`
27+
`Unable to open ${pageUrl} in browser${openOptionValue}. If you are running in a headless environment, please do not use the --open flag`
2828
);
2929
});
3030
})

test/server/utils/runOpen.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ describe('runOpen util', () => {
181181
it('on specify URL and log error', () => {
182182
return runOpen('https://example.com', {}, logMock).then(() => {
183183
expect(logMock.warn.mock.calls[0][0]).toMatchInlineSnapshot(
184-
`"Unable to open browser. If you are running in a headless environment, please do not use the --open flag"`
184+
`"Unable to open https://example.com in browser. If you are running in a headless environment, please do not use the --open flag"`
185185
);
186186
expect(opn.mock.calls[0]).toMatchInlineSnapshot(`
187187
Array [
@@ -201,7 +201,7 @@ describe('runOpen util', () => {
201201
logMock
202202
).then(() => {
203203
expect(logMock.warn.mock.calls[0][0]).toMatchInlineSnapshot(
204-
`"Unable to open browser. If you are running in a headless environment, please do not use the --open flag"`
204+
`"Unable to open https://example.com/index.html in browser. If you are running in a headless environment, please do not use the --open flag"`
205205
);
206206
expect(opn.mock.calls[0]).toMatchInlineSnapshot(`
207207
Array [
@@ -221,7 +221,7 @@ describe('runOpen util', () => {
221221
logMock
222222
).then(() => {
223223
expect(logMock.warn.mock.calls[0][0]).toMatchInlineSnapshot(
224-
`"Unable to open browser: Google Chrome. If you are running in a headless environment, please do not use the --open flag"`
224+
`"Unable to open https://example.com in browser: Google Chrome. If you are running in a headless environment, please do not use the --open flag"`
225225
);
226226
expect(opn.mock.calls[0]).toMatchInlineSnapshot(`
227227
Array [
@@ -242,7 +242,7 @@ describe('runOpen util', () => {
242242
logMock
243243
).then(() => {
244244
expect(logMock.warn.mock.calls[0][0]).toMatchInlineSnapshot(
245-
`"Unable to open browser: Google Chrome. If you are running in a headless environment, please do not use the --open flag"`
245+
`"Unable to open https://example.com/index.html in browser: Google Chrome. If you are running in a headless environment, please do not use the --open flag"`
246246
);
247247
expect(opn.mock.calls[0]).toMatchInlineSnapshot(`
248248
Array [

0 commit comments

Comments
 (0)