From a2a51022546aafbbc916902e0054933500dac64b Mon Sep 17 00:00:00 2001 From: eslam Date: Wed, 25 Sep 2019 16:24:00 +0200 Subject: [PATCH] refactor: update snapshot & change clientSocketOptions type to Object --- lib/options.json | 33 ++++++++++--------- lib/utils/createConfig.js | 2 +- test/options.test.js | 4 +-- .../__snapshots__/createConfig.test.js.snap | 12 +++++-- 4 files changed, 29 insertions(+), 22 deletions(-) diff --git a/lib/options.json b/lib/options.json index c2b65dcc16..d12f058346 100644 --- a/lib/options.json +++ b/lib/options.json @@ -40,23 +40,24 @@ "enum": ["info", "warn", "error", "debug", "trace", "silent"] }, "clientSocketOptions": { - "anyOf": [ - { - "type": "array" + "type": "object", + "properties": { + "host": { + "type": "string" }, - { - "type": "object" + "path": { + "type": "string" + }, + "port": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "number" + } + ] } - ], - "items": { - "anyOf": [ - { - "type": "number" - }, - { - "type": "string" - } - ] } }, "compress": { @@ -404,7 +405,7 @@ "ca": "should be {String|Buffer}", "cert": "should be {String|Buffer}", "clientLogLevel": "should be {String} and equal to one of the allowed values\n\n [ 'silent', 'info', 'debug', 'trace', 'error', 'warn' ]\n\n (https://webpack.js.org/configuration/dev-server/#devserverclientloglevel)", - "clientSocketOptions": "should be {Array} (https://webpack.js.org/configuration/dev-server/#devserverclientsocketoptions)", + "clientSocketOptions": "should be {Object} (https://webpack.js.org/configuration/dev-server/#devserverclientsocketoptions)", "compress": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devservercompress)", "contentBase": "should be {Number|String|Array} (https://webpack.js.org/configuration/dev-server/#devservercontentbase)", "disableHostCheck": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverdisablehostcheck)", diff --git a/lib/utils/createConfig.js b/lib/utils/createConfig.js index ae1be7a511..8e7475035f 100644 --- a/lib/utils/createConfig.js +++ b/lib/utils/createConfig.js @@ -35,7 +35,7 @@ function createConfig(config, argv, { port }) { (argv.sockHost || argv.sockPath || argv.sockPort) && !options.clientSocketOptions ) { - options.clientSocketOptions = []; + options.clientSocketOptions = {}; } if (argv.sockHost) { diff --git a/test/options.test.js b/test/options.test.js index e3ab831442..1c28806cf7 100644 --- a/test/options.test.js +++ b/test/options.test.js @@ -291,8 +291,8 @@ describe('options', () => { failure: [false], }, clientSocketOptions: { - success: [[], ['']], - failure: [[false], false], + success: [{}], + failure: [false], }, staticOptions: { success: [{}], diff --git a/test/server/utils/__snapshots__/createConfig.test.js.snap b/test/server/utils/__snapshots__/createConfig.test.js.snap index 585d74105c..9e9b6ea851 100644 --- a/test/server/utils/__snapshots__/createConfig.test.js.snap +++ b/test/server/utils/__snapshots__/createConfig.test.js.snap @@ -1202,12 +1202,14 @@ Object { exports[`createConfig sockHost option 1`] = ` Object { + "clientSocketOptions": Object { + "host": true, + }, "hot": true, "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", - "sockHost": true, "stats": Object { "cached": false, "cachedAssets": false, @@ -1217,12 +1219,14 @@ Object { exports[`createConfig sockPath option 1`] = ` Object { + "clientSocketOptions": Object { + "path": "path", + }, "hot": true, "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", - "sockPath": "path", "stats": Object { "cached": false, "cachedAssets": false, @@ -1232,12 +1236,14 @@ Object { exports[`createConfig sockPort option 1`] = ` Object { + "clientSocketOptions": Object { + "port": "port", + }, "hot": true, "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", - "sockPort": "port", "stats": Object { "cached": false, "cachedAssets": false,