]> khamidou — GitHub mirrors - electron.git/commitdiff
Fix `process.std*.write`
authorEran Tiktin <eran.t@mce-sys.com>
Sat, 10 Oct 2015 05:13:27 +0000 (08:13 +0300)
committerEran Tiktin <eran.t@mce-sys.com>
Sat, 10 Oct 2015 05:13:27 +0000 (08:13 +0300)
- Support printing Buffer
- Don't add '\n' at the end the chunk

atom/browser/lib/init.coffee

index 2b6b1bb3c239cb426b3c44f806176e479a0fd8aa..9f92d700c73a192b615f1ee9bd2f7cb3226cbceb 100644 (file)
@@ -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