From 61451187a874d9daf007bf7946f9da3341511f2a Mon Sep 17 00:00:00 2001 From: Rotzbua Date: Tue, 5 Sep 2023 14:50:17 +0200 Subject: [PATCH] Remove outdated Node <16 checks --- .../@node-red/registry/lib/externalModules.js | 17 ----------------- packages/node_modules/node-red/lib/red.js | 7 ++----- test/nodes/core/network/21-httprequest_spec.js | 3 +-- 3 files changed, 3 insertions(+), 24 deletions(-) diff --git a/packages/node_modules/@node-red/registry/lib/externalModules.js b/packages/node_modules/@node-red/registry/lib/externalModules.js index b76f748a4..04319fc71 100644 --- a/packages/node_modules/@node-red/registry/lib/externalModules.js +++ b/packages/node_modules/@node-red/registry/lib/externalModules.js @@ -28,11 +28,6 @@ let installEnabled = true; let installAllowList = ['*']; let installDenyList = []; -let IMPORT_SUPPORTED = true; -const nodeVersionParts = process.versions.node.split(".").map(v => parseInt(v)); -if (nodeVersionParts[0] < 12 || (nodeVersionParts[0] === 12 && nodeVersionParts[1] < 17)) { - IMPORT_SUPPORTED = false; -} function getInstallDir() { return path.resolve(settings.userDir || process.env.NODE_RED_HOME || "."); @@ -110,18 +105,6 @@ function requireModule(module) { return require(moduleDir); } function importModule(module) { - if (!IMPORT_SUPPORTED) { - // On Node < 12.17 - fall back to try a require - return new Promise((resolve, reject) => { - try { - const mod = requireModule(module); - resolve(mod); - } catch(err) { - reject(err); - } - }); - } - if (!registryUtil.checkModuleAllowed( module, null,installAllowList,installDenyList)) { const e = new Error("Module not allowed"); e.code = "module_not_allowed"; diff --git a/packages/node_modules/node-red/lib/red.js b/packages/node_modules/node-red/lib/red.js index a61adf1c2..b6e6c0d5f 100644 --- a/packages/node_modules/node-red/lib/red.js +++ b/packages/node_modules/node-red/lib/red.js @@ -25,11 +25,8 @@ var api = require("@node-red/editor-api"); var server = null; var apiEnabled = false; -const NODE_MAJOR_VERSION = process.versions.node.split('.')[0]; -if (NODE_MAJOR_VERSION > 14) { - const dns = require('node:dns'); - dns.setDefaultResultOrder('ipv4first'); -} +const dns = require('node:dns'); +dns.setDefaultResultOrder('ipv4first'); function checkVersion(userSettings) { var semver = require('semver'); diff --git a/test/nodes/core/network/21-httprequest_spec.js b/test/nodes/core/network/21-httprequest_spec.js index bace012b5..16e46b357 100644 --- a/test/nodes/core/network/21-httprequest_spec.js +++ b/test/nodes/core/network/21-httprequest_spec.js @@ -2476,8 +2476,7 @@ describe('HTTP Request Node', function() { const versions = process.versions.node.split('.') - if (( versions[0] == 14 && versions[1] >= 20 ) || - ( versions[0] == 16 && versions[1] >= 16 ) || + if (( versions[0] == 16 && versions[1] >= 16 ) || ( versions[0] == 18 && versions[1] >= 5 ) || ( versions[0] > 18)) { // only test if on new enough NodeJS version