diff --git a/lib/options.json b/lib/options.json index 703e2b5657..0b01be6dac 100644 --- a/lib/options.json +++ b/lib/options.json @@ -198,6 +198,12 @@ }, { "type": "boolean" + }, + { + "type": "array", + "items": { + "type": "string" + } } ] }, diff --git a/lib/utils/status.js b/lib/utils/status.js index f9acb1aa6c..070db0322b 100644 --- a/lib/utils/status.js +++ b/lib/utils/status.js @@ -46,7 +46,7 @@ function status(uri, options, log, useColor) { let openOptions = {}; let openMessage = 'Unable to open browser'; - if (typeof options.open === 'string') { + if (typeof options.open === 'string' || Array.isArray(options.open)) { openOptions = { app: options.open }; openMessage += `: ${options.open}`; } diff --git a/test/CreateConfig.test.js b/test/CreateConfig.test.js index 5cce86344f..c7e622ea02 100644 --- a/test/CreateConfig.test.js +++ b/test/CreateConfig.test.js @@ -909,4 +909,38 @@ describe('createConfig', () => { ).toMatchSnapshot(); expect(webpackConfigNoStats).toMatchSnapshot(); }); + + it('open true', () => { + const config = createConfig( + webpackConfig, + Object.assign({}, argv, { + open: true, + }), + { port: 8080 } + ); + + expect(config).toMatchSnapshot(); + }); + + it('open application', () => { + const config = createConfig( + webpackConfig, + Object.assign({}, argv, { + openPage: 'Google Chrome', + }), + { port: 8080 } + ); + expect(config).toMatchSnapshot(); + }); + + it('open application with args', () => { + const config = createConfig( + webpackConfig, + Object.assign({}, argv, { + openPage: ['Google Chrome', '--incognito'], + }), + { port: 8080 } + ); + expect(config).toMatchSnapshot(); + }); }); diff --git a/test/__snapshots__/CreateConfig.test.js.snap b/test/__snapshots__/CreateConfig.test.js.snap index bd0044f1a4..a6a8514677 100644 --- a/test/__snapshots__/CreateConfig.test.js.snap +++ b/test/__snapshots__/CreateConfig.test.js.snap @@ -712,6 +712,41 @@ Object { } `; +exports[`createConfig open application 1`] = ` +Object { + "hot": true, + "hotOnly": false, + "noInfo": true, + "open": true, + "openPage": "Google Chrome", + "port": 8080, + "publicPath": "/", + "stats": Object { + "cached": false, + "cachedAssets": false, + }, +} +`; + +exports[`createConfig open application with args 1`] = ` +Object { + "hot": true, + "hotOnly": false, + "noInfo": true, + "open": true, + "openPage": Array [ + "Google Chrome", + "--incognito", + ], + "port": 8080, + "publicPath": "/", + "stats": Object { + "cached": false, + "cachedAssets": false, + }, +} +`; + exports[`createConfig open option (boolean) (in devServer config) 1`] = ` Object { "hot": true, @@ -760,6 +795,22 @@ Object { } `; +exports[`createConfig open true 1`] = ` +Object { + "hot": true, + "hotOnly": false, + "noInfo": true, + "open": true, + "openPage": "", + "port": 8080, + "publicPath": "/", + "stats": Object { + "cached": false, + "cachedAssets": false, + }, +} +`; + exports[`createConfig openPage option (in devServer config) 1`] = ` Object { "hot": true,