From b0f453f2dda02bbc433637801ace8b57be050b2c Mon Sep 17 00:00:00 2001 From: cjihrig Date: Sun, 11 Mar 2018 10:33:42 -0400 Subject: [PATCH] lib: define printErr() in script string This commit moves the printErr() function, used by the tick profiler processer, into the code string passed to vm.runInThisContext(). --- lib/internal/v8_prof_processor.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/internal/v8_prof_processor.js b/lib/internal/v8_prof_processor.js index 08c712f8be0daf..6c7a4db6641935 100644 --- a/lib/internal/v8_prof_processor.js +++ b/lib/internal/v8_prof_processor.js @@ -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'); @@ -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);