Fix process.std*.write

- Support printing Buffer
- Don't add '\n' at the end the chunk
This commit is contained in:
Eran Tiktin 2015-10-10 08:13:27 +03:00
parent 1896deb10e
commit c71efc8ca5

View file

@ -21,10 +21,15 @@ globalPaths.push path.resolve(__dirname, '..', 'api', 'lib')
if process.platform is 'win32' if process.platform is 'win32'
# Redirect node's console to use our own implementations, since node can not # Redirect node's console to use our own implementations, since node can not
# handle console output when running as GUI program. # handle console output when running as GUI program.
print = (args...) -> consoleLog = (args...) ->
process.log util.format(args...) + "\n" process.log util.format(args...) + "\n"
console.log = console.error = console.warn = print streamWrite = (chunk, encoding, callback) ->
process.stdout.write = process.stderr.write = print 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. # Always returns EOF for stdin stream.
Readable = require('stream').Readable Readable = require('stream').Readable