fix(Server): correct `node` version checks (#1543) · webpack/webpack-dev-server@927a2b3

Original file line numberDiff line numberDiff line change

@@ -20,6 +20,8 @@ const https = require('https');

2020

const spdy = require('spdy');

2121

const sockjs = require('sockjs');

2222
23+

const semver = require('semver');

24+
2325

const killable = require('killable');

2426
2527

const del = require('del');

@@ -46,8 +48,7 @@ const schema = require('./options.json');

4648

// breaking connection when certificate is not signed with prime256v1

4749

// change it to auto allows OpenSSL to select the curve automatically

4850

// See https://github.com/nodejs/node/issues/16196 for more infomation

49-

const version = parseFloat(process.version.slice(1));

50-

if (version >= 8.6 && version < 10) {

51+

if (semver.satisfies(process.version, '8.6.0 - 9')) {

5152

tls.DEFAULT_ECDH_CURVE = 'auto';

5253

}

5354

@@ -592,7 +593,7 @@ function Server (compiler, options = {}, _log) {

592593

// - https://github.com/nodejs/node/issues/21665

593594

// - https://github.com/webpack/webpack-dev-server/issues/1449

594595

// - https://github.com/expressjs/express/issues/3388

595-

if (version >= 10) {

596+

if (semver.gte(process.version, '10.0.0')) {

596597

this.listeningApp = https.createServer(options.https, app);

597598

} else {

598599

this.listeningApp = spdy.createServer(options.https, app);