From 9cd5ea14063d56e883ca8ba34a9b498ff480d66a Mon Sep 17 00:00:00 2001 From: Johannes Ewald Date: Sat, 11 Nov 2017 03:24:37 +0100 Subject: Remove legacy code for node < 4 --- lib/rewire.js | 8 -------- test/getImportGlobalsSrc.test.js | 14 ++------------ 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/lib/rewire.js b/lib/rewire.js index cbd24c2..e678f37 100644 --- a/lib/rewire.js +++ b/lib/rewire.js @@ -23,14 +23,6 @@ function internalRewire(parentModulePath, targetPath) { // Resolve full filename relative to the parent module targetPath = Module._resolveFilename(targetPath, parentModulePath); - // Special support for older node versions that returned an array on Module._resolveFilename - // @see https://github.com/joyent/node/blob/865b077819a9271a29f982faaef99dc635b57fbc/lib/module.js#L319 - // TODO Remove this switch on the next major release - /* istanbul ignore next because it will be removed soon */ - if (Array.isArray(targetPath)) { - targetPath = targetPath[1]; - } - // Create testModule as it would be created by require() targetModule = new Module(targetPath, parentModulePath); diff --git a/test/getImportGlobalsSrc.test.js b/test/getImportGlobalsSrc.test.js index 28ac50c..0c40e5a 100644 --- a/test/getImportGlobalsSrc.test.js +++ b/test/getImportGlobalsSrc.test.js @@ -31,12 +31,7 @@ describe("getImportGlobalsSrc", function () { expectedGlobals = Object.keys(global); vm.runInNewContext(src, context); - actualGlobals = Object.keys(context).filter(function (key) { - // node v0.10 does not set a constructor property on the context - // node v0.11 does set a constructor property - // so just lets filter it, because it doesn't make sense to mock it anyway - return key !== "constructor"; - }); + actualGlobals = Object.keys(context); actualGlobals.sort(); expectedGlobals.sort(); expect(actualGlobals).to.eql(expectedGlobals); @@ -57,12 +52,7 @@ describe("getImportGlobalsSrc", function () { return ignore.indexOf(value) === -1; }); vm.runInNewContext(src, context); - actualGlobals = Object.keys(context).filter(function (key) { - // node v0.10 does not set a constructor property on the context - // node v0.11 does set a constructor property - // so just lets filter it, because it doesn't make sense to mock it anyway - return key !== "constructor" - }); + actualGlobals = Object.keys(context); actualGlobals.sort(); expectedGlobals.sort(); expect(actualGlobals).to.eql(expectedGlobals); -- cgit v1.2.3