Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(options): add multiple openPage support #2266

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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`
digitaljohn marked this conversation as resolved.
Show resolved Hide resolved
);
});
})
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