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 authored and BridgeAR committed Feb 17, 2018
1 parent 38f04d4 commit 99d693d
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',
'internal/deps/v8/tools/splaytree',
Expand Down Expand Up @@ -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);

0 comments on commit 99d693d

Please sign in to comment.