From 16b9f8995df5fe0097bca3eea31aae2e2b3749a4 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 16 Oct 2015 17:38:11 +0800 Subject: [PATCH] Revert "Go back to using node's console.* and std*.write" This reverts commit 4e8db2c3be8f3c9a172fb87ad8739493ab3dfbb1. It seems that we still have problems with Node.js's console.* calls, I'm reverting this for now unitl we get a solution. Fixes #3100. --- atom/browser/lib/init.coffee | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/atom/browser/lib/init.coffee b/atom/browser/lib/init.coffee index 67630a1bd6fa..9f92d700c73a 100644 --- a/atom/browser/lib/init.coffee +++ b/atom/browser/lib/init.coffee @@ -18,6 +18,25 @@ require path.resolve(__dirname, '..', '..', 'common', 'lib', 'init') globalPaths = Module.globalPaths globalPaths.push path.resolve(__dirname, '..', 'api', 'lib') +if process.platform is 'win32' + # Redirect node's console to use our own implementations, since node can not + # handle console output when running as GUI program. + consoleLog = (args...) -> + process.log util.format(args...) + "\n" + streamWrite = (chunk, encoding, callback) -> + chunk = chunk.toString(encoding) if Buffer.isBuffer chunk + process.log chunk + callback() if callback + true + console.log = console.error = console.warn = consoleLog + process.stdout.write = process.stderr.write = streamWrite + + # Always returns EOF for stdin stream. + Readable = require('stream').Readable + stdin = new Readable + stdin.push null + process.__defineGetter__ 'stdin', -> stdin + # Don't quit on fatal error. process.on 'uncaughtException', (error) -> # Do nothing if the user has a custom uncaught exception handler.