Call process.log from fallback stream on Windows

(cherry picked from commit d31e629b4f2daf3500a485caab2b2990a41e3ad4)
This commit is contained in:
Kevin Sawicki 2016-10-12 09:43:26 -07:00 коммит произвёл Aleksei Kuzmin
Родитель ef843c373f
Коммит 85d3f5488e
1 изменённых файлов: 7 добавлений и 2 удалений

Просмотреть файл

@ -153,11 +153,16 @@ function setupStdio() {
};
}
function createDevNull() {
function createFallbackStream() {
var Writable = process.NativeModule.require('stream').Writable;
var stream = new Writable;
stream.isTTY = false;
stream._write = function(chunk, encoding, callback) {
if (process.platform === 'win32' &&
process.env.ELECTRON_RUN_AS_NODE &&
!process.env.ELECTRON_NO_ATTACH_CONSOLE) {
process.log(chunk.toString());
}
process.nextTick(callback);
};
return stream;
@ -201,7 +206,7 @@ function createWritableStdioStream(fd) {
// Ignore stream errors.
stream.on('error', function() {});
} catch (error) {
stream = createDevNull();
stream = createFallbackStream();
}
// For supporting legacy API we put the FD here.