Skip to content

Commit

Permalink
lib: define printErr() in script string
Browse files Browse the repository at this point in the history
This commit moves the printErr() function, used by the
tick profiler processer, into the code string passed to
vm.runInThisContext().

PR-URL: nodejs#19285
Fixes: nodejs#19260
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
cjihrig authored and MayaLekova committed May 8, 2018
1 parent 1a6d8d3 commit 4824c10
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions lib/internal/v8_prof_processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ scriptFiles.forEach(function(s) {
script += process.binding('natives')[s] + '\n';
});

// eslint-disable-next-line no-unused-vars
function printErr(err) {
console.error(err);
}

const tickArguments = [];
if (process.platform === 'darwin') {
tickArguments.push('--mac');
Expand All @@ -37,6 +32,7 @@ tickArguments.push.apply(tickArguments, process.argv.slice(1));
script = `(function(module, require) {
arguments = ${JSON.stringify(tickArguments)};
function write (s) { process.stdout.write(s) }
function printErr(err) { console.error(err); }
${script}
})`;
vm.runInThisContext(script)(module, require);

0 comments on commit 4824c10

Please sign in to comment.