fix: no more need to hijack process.stdout on Win32 (#25765)
This commit is contained in:
parent
9717dff4fa
commit
57dc170e81
10 changed files with 9 additions and 63 deletions
|
@ -1,9 +1,6 @@
|
|||
import { Buffer } from 'buffer';
|
||||
import { EventEmitter } from 'events';
|
||||
import * as fs from 'fs';
|
||||
import { Socket } from 'net';
|
||||
import * as path from 'path';
|
||||
import * as util from 'util';
|
||||
|
||||
const Module = require('module');
|
||||
|
||||
|
@ -19,28 +16,6 @@ require('@electron/internal/common/init');
|
|||
|
||||
process._linkedBinding('electron_browser_event_emitter').setEventEmitterPrototype(EventEmitter.prototype);
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
// Redirect node's console to use our own implementations, since node can not
|
||||
// handle console output when running as GUI program.
|
||||
const consoleLog = (...args: any[]) => {
|
||||
// @ts-ignore this typing is incorrect; 'format' is an optional parameter
|
||||
// See https://nodejs.org/api/util.html#util_util_format_format_args
|
||||
return process.log(util.format(...args) + '\n');
|
||||
};
|
||||
const streamWrite: Socket['write'] = function (chunk: Buffer | string, encoding?: any, callback?: Function) {
|
||||
if (Buffer.isBuffer(chunk)) {
|
||||
chunk = chunk.toString(encoding);
|
||||
}
|
||||
process.log(chunk);
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
return true;
|
||||
};
|
||||
console.log = console.error = console.warn = consoleLog;
|
||||
process.stdout.write = process.stderr.write = streamWrite;
|
||||
}
|
||||
|
||||
// Don't quit on fatal error.
|
||||
process.on('uncaughtException', function (error) {
|
||||
// Do nothing if the user has a custom uncaught exception handler.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue