Skip to content

Commit

Permalink
lib: replace eval with vm.runInThisContext
Browse files Browse the repository at this point in the history
PR-URL: #18623
Refs: #18212 (review)
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>
  • Loading branch information
MylesBorins committed Feb 21, 2018
1 parent 1bff0aa commit 810925b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/internal/v8_prof_processor.js
@@ -1,4 +1,7 @@
/* eslint-disable strict */
'use strict';

const vm = require('vm');

const scriptFiles = [
'internal/v8_prof_polyfill',
'v8/tools/splaytree',
Expand Down Expand Up @@ -30,9 +33,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);

0 comments on commit 810925b

Please sign in to comment.