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 <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
  • Loading branch information
MylesBorins committed Feb 21, 2018
1 parent d1ff8fa commit 47dfe29
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/internal/v8_prof_processor.js
Original file line number Diff line number Diff line change
@@ -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 47dfe29

Please sign in to comment.