From 2bb9c37295fb8f432284b24b990d5b014b6a1361 Mon Sep 17 00:00:00 2001 From: Alex J Burke Date: Wed, 1 Jan 2020 23:13:41 +0100 Subject: [PATCH] Roll back the use of Object.assign() in evaluateSnippets. This is required for fiddling with the global object on node 8. --- lib/evaluateSnippets.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/evaluateSnippets.js b/lib/evaluateSnippets.js index 5a996a9..083ab10 100644 --- a/lib/evaluateSnippets.js +++ b/lib/evaluateSnippets.js @@ -26,6 +26,16 @@ try { }; } +function extend(target) { + for (var i = 1; i < arguments.length; i += 1) { + var source = arguments[i]; + Object.keys(source).forEach(function(key) { + target[key] = source[key]; + }); + } + return target; +} + function isPromise(value) { return ( value && @@ -55,7 +65,7 @@ function getErrorMessage(expect, format, error) { } module.exports = async function(snippets, options) { - var oldGlobal = Object.assign({}, global); + var oldGlobal = extend({}, global); var expect = createExpect(options); global.expect = expect.clone(); global.require = require; @@ -137,5 +147,6 @@ module.exports = async function(snippets, options) { } }); - Object.assign(global, oldGlobal); + // local function used for compatibility with node 8 + extend(global, oldGlobal); };