From c71efc8ca54b1f7f4de799eca8c0e49bb558c2e7 Mon Sep 17 00:00:00 2001 From: Eran Tiktin Date: Sat, 10 Oct 2015 08:13:27 +0300 Subject: [PATCH] Fix `process.std*.write` - Support printing Buffer - Don't add '\n' at the end the chunk --- atom/browser/lib/init.coffee | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/atom/browser/lib/init.coffee b/atom/browser/lib/init.coffee index 2b6b1bb3c2..9f92d700c7 100644 --- a/atom/browser/lib/init.coffee +++ b/atom/browser/lib/init.coffee @@ -21,10 +21,15 @@ 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. - print = (args...) -> + consoleLog = (args...) -> process.log util.format(args...) + "\n" - console.log = console.error = console.warn = print - process.stdout.write = process.stderr.write = print + 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