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(). PR-URL: https://github.com/nodejs/node/pull/19285 Fixes: https://github.com/nodejs/node/issues/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>
This commit is contained in:
parent
148d16ab5b
commit
22b6804259
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user