Skip to content

Commit

Permalink
fix: runOpen - made warning output related url
Browse files Browse the repository at this point in the history
  • Loading branch information
John Chipps-Harding committed Oct 2, 2019
1 parent c727994 commit df0384e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions lib/utils/runOpen.js
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
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

0 comments on commit df0384e

Please sign in to comment.