Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/utils/runOpen.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ const isAbsoluteUrl = require('is-absolute-url');
function runOpen(uri, options, log) {
// https://github.com/webpack/webpack-dev-server/issues/1990
let openOptions = { wait: false };
let openMessage = 'Unable to open browser';
let openOptionValue = '';

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

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

return open(pageUrl, openOptions).catch(() => {
log.warn(
`${openMessage}. If you are running in a headless environment, please do not use the --open flag`
`Unable to open ${pageUrl} in browser${openOptionValue}. If you are running in a headless environment, please do not use the --open flag`
);
});
})
Expand Down
8 changes: 4 additions & 4 deletions test/server/utils/runOpen.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ describe('runOpen util', () => {
it('on specify URL and log error', () => {
return runOpen('https://example.com', {}, logMock).then(() => {
expect(logMock.warn.mock.calls[0][0]).toMatchInlineSnapshot(
`"Unable to open browser. If you are running in a headless environment, please do not use the --open flag"`
`"Unable to open https://example.com in browser. If you are running in a headless environment, please do not use the --open flag"`
);
expect(opn.mock.calls[0]).toMatchInlineSnapshot(`
Array [
Expand All @@ -201,7 +201,7 @@ describe('runOpen util', () => {
logMock
).then(() => {
expect(logMock.warn.mock.calls[0][0]).toMatchInlineSnapshot(
`"Unable to open browser. If you are running in a headless environment, please do not use the --open flag"`
`"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"`
);
expect(opn.mock.calls[0]).toMatchInlineSnapshot(`
Array [
Expand All @@ -221,7 +221,7 @@ describe('runOpen util', () => {
logMock
).then(() => {
expect(logMock.warn.mock.calls[0][0]).toMatchInlineSnapshot(
`"Unable to open browser: Google Chrome. If you are running in a headless environment, please do not use the --open flag"`
`"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"`
);
expect(opn.mock.calls[0]).toMatchInlineSnapshot(`
Array [
Expand All @@ -242,7 +242,7 @@ describe('runOpen util', () => {
logMock
).then(() => {
expect(logMock.warn.mock.calls[0][0]).toMatchInlineSnapshot(
`"Unable to open browser: Google Chrome. If you are running in a headless environment, please do not use the --open flag"`
`"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"`
);
expect(opn.mock.calls[0]).toMatchInlineSnapshot(`
Array [
Expand Down