Skip to content

Commit

Permalink
Update devServer.options to take an array as well as a string to ma…
Browse files Browse the repository at this point in the history
…ke it consistent with the underlying library, open

https://www.npmjs.com/package/open
  • Loading branch information
dangreenisrael committed Apr 8, 2019
1 parent 99e8db0 commit ec7cb84
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@
},
{
"type": "boolean"
},
{
"type": "array",
"items": {
"type": "string"
}
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
}
Expand Down
34 changes: 34 additions & 0 deletions test/CreateConfig.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
51 changes: 51 additions & 0 deletions test/__snapshots__/CreateConfig.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit ec7cb84

Please sign in to comment.