From 2ae98ce7cb95dee79e839afb2ee4c7d77d7670cd 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 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit moves the printErr() function, used by the tick profiler processer, into the code string passed to vm.runInThisContext(). PR-URL: https://github.com/nodejs/node/pull/19285 Fixes: https://github.com/nodejs/node/issues/19260 Reviewed-By: Michaël Zasso Reviewed-By: Gus Caplan Reviewed-By: Daniel Bevenius Reviewed-By: James M Snell Reviewed-By: Tobias Nießen Reviewed-By: Ruben Bridgewater --- 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 7592253060294c..4799a88f69ca54 100644 --- a/lib/internal/v8_prof_processor.js +++ b/lib/internal/v8_prof_processor.js @@ -21,11 +21,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'); @@ -36,6 +31,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);