From 927a2b38d4d3a5d8fd50dfce0343634d46fa8a92 Mon Sep 17 00:00:00 2001 From: nekolab Date: Fri, 26 Oct 2018 05:55:16 +0800 Subject: [PATCH] fix(Server): correct `node` version checks (#1543) --- lib/Server.js | 7 ++++--- package-lock.json | 6 +++--- package.json | 1 + 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/Server.js b/lib/Server.js index 065dc08bee..df60ccff74 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -20,6 +20,8 @@ const https = require('https'); const spdy = require('spdy'); const sockjs = require('sockjs'); +const semver = require('semver'); + const killable = require('killable'); const del = require('del'); @@ -46,8 +48,7 @@ const schema = require('./options.json'); // breaking connection when certificate is not signed with prime256v1 // change it to auto allows OpenSSL to select the curve automatically // See https://github.com/nodejs/node/issues/16196 for more infomation -const version = parseFloat(process.version.slice(1)); -if (version >= 8.6 && version < 10) { +if (semver.satisfies(process.version, '8.6.0 - 9')) { tls.DEFAULT_ECDH_CURVE = 'auto'; } @@ -592,7 +593,7 @@ function Server (compiler, options = {}, _log) { // - https://github.com/nodejs/node/issues/21665 // - https://github.com/webpack/webpack-dev-server/issues/1449 // - https://github.com/expressjs/express/issues/3388 - if (version >= 10) { + if (semver.gte(process.version, '10.0.0')) { this.listeningApp = https.createServer(options.https, app); } else { this.listeningApp = spdy.createServer(options.https, app); diff --git a/package-lock.json b/package-lock.json index 57aaae5d90..8ae788f717 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10393,9 +10393,9 @@ } }, "semver": { - "version": "5.5.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.1.tgz", - "integrity": "sha512-PqpAxfrEhlSUWge8dwIp4tZnQ25DIOthpiaHNIthsjEFQD6EvqUKUDM7L8O2rShkFccYo1VjJR0coWfNkCubRw==" + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", + "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==" }, "send": { "version": "0.16.2", diff --git a/package.json b/package.json index 47452e1c31..e3ee55f5e6 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "portfinder": "^1.0.9", "schema-utils": "^1.0.0", "selfsigned": "^1.9.1", + "semver": "^5.6.0", "serve-index": "^1.7.2", "sockjs": "0.3.19", "sockjs-client": "1.3.0",