0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00

lib: replace eval with vm.runInThisContext

PR-URL: https://github.com/nodejs/node/pull/18623
Refs: https://github.com/nodejs/node/pull/18212#pullrequestreview-94616927
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
Myles Borins 2018-02-07 10:42:26 -05:00 committed by Ruben Bridgewater
parent 38f04d4da1
commit 99d693da5c
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762

View File

@ -1,4 +1,7 @@
/* eslint-disable strict */
'use strict';
const vm = require('vm');
const scriptFiles = [
'internal/v8_prof_polyfill',
'internal/deps/v8/tools/splaytree',
@ -31,9 +34,9 @@ if (process.platform === 'darwin') {
tickArguments.push('--windows');
}
tickArguments.push.apply(tickArguments, process.argv.slice(1));
script = `(function() {
script = `(function(require) {
arguments = ${JSON.stringify(tickArguments)};
function write (s) { process.stdout.write(s) }
${script}
})()`;
eval(script);
})`;
vm.runInThisContext(script)(require);