Skip to content

Commit

Permalink
Roll back the use of Object.assign() in evaluateSnippets.
Browse files Browse the repository at this point in the history
This is required for fiddling with the global object on node 8.
  • Loading branch information
alexjeffburke committed Jan 1, 2020
1 parent cf4083f commit 2bb9c37
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/evaluateSnippets.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
};

0 comments on commit 2bb9c37

Please sign in to comment.