mirror of
https://github.com/nodejs/node-v0.x-archive.git
synced 2026-04-28 03:01:10 -04:00
Encoding 0 length data, returns '' instead of null
This commit is contained in:
@@ -170,7 +170,7 @@ enum encoding ParseEncoding(Handle<Value> encoding_v, enum encoding _default) {
|
||||
Local<Value> Encode(const void *buf, size_t len, enum encoding encoding) {
|
||||
HandleScope scope;
|
||||
|
||||
if (!len) return scope.Close(Null());
|
||||
if (!len) return scope.Close(String::Empty());
|
||||
|
||||
if (encoding == BINARY) {
|
||||
const unsigned char *cbuf = static_cast<const unsigned char*>(buf);
|
||||
|
||||
@@ -200,7 +200,9 @@ void ChildProcess::on_read(evcom_reader *r, const void *buf, size_t len) {
|
||||
enum encoding encoding = isSTDOUT ?
|
||||
child->stdout_encoding_ : child->stderr_encoding_;
|
||||
|
||||
Local<Value> data = Encode(buf, len, encoding);
|
||||
// TODO emit 'end' event instead of null.
|
||||
|
||||
Local<Value> data = len ? Encode(buf, len, encoding) : Local<Value>::New(Null());
|
||||
child->Emit(isSTDOUT ? output_symbol : error_symbol, 1, &data);
|
||||
child->MaybeShutdown();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user