Skip to content

Commit

Permalink
Merge pull request #13 from TooTallNate/patch-1
Browse files Browse the repository at this point in the history
Only copy ctx properties when `context` is defined
  • Loading branch information
goto-bus-stop authored Mar 22, 2018
2 parents 7fc6c72 + b9c1cc7 commit c15bc7f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,11 @@ Script.prototype.runInNewContext = function (context) {
var ctx = Script.createContext(context);
var res = this.runInContext(ctx);

forEach(Object_keys(ctx), function (key) {
context[key] = ctx[key];
});
if (context) {
forEach(Object_keys(ctx), function (key) {
context[key] = ctx[key];
});
}

return res;
};
Expand Down

0 comments on commit c15bc7f

Please # to comment.