[Pkg-javascript-commits] [uglifyjs] 200/228: workaround Node.js bugs (#1775)

Jonas Smedegaard dr at jones.dk
Sat Apr 15 14:25:30 UTC 2017


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository uglifyjs.

commit a4007418683f55fec52b8085bac5e4d545b70a0e
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Mon Apr 3 18:56:11 2017 +0800

    workaround Node.js bugs (#1775)
    
    Wrap test code in IIFE before passing to `vm`
    
    fixes #1768
    fixes #1771
---
 test/sandbox.js | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/test/sandbox.js b/test/sandbox.js
index 396a6e2..ea3a60a 100644
--- a/test/sandbox.js
+++ b/test/sandbox.js
@@ -12,7 +12,6 @@ var FUNC_TOSTRING = [
     '        return "[Function: __func_" + i + "__]";',
     "    }",
     "}();",
-    ""
 ].join("\n");
 exports.run_code = function(code) {
     var stdout = "";
@@ -21,7 +20,12 @@ exports.run_code = function(code) {
         stdout += chunk;
     };
     try {
-        new vm.Script(FUNC_TOSTRING + code).runInNewContext({
+        vm.runInNewContext([
+            "!function() {",
+            FUNC_TOSTRING,
+            code,
+            "}();",
+        ].join("\n"), {
             console: {
                 log: function() {
                     return console.log.apply(console, [].map.call(arguments, function(arg) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git



More information about the Pkg-javascript-commits mailing list