From 6c30ec566d1d98a4ad878687354c6bcffa739b46 Mon Sep 17 00:00:00 2001 From: Dmitry Yakimenko Date: Thu, 14 Jul 2016 17:03:08 +0200 Subject: [PATCH 1/2] Fixed unsupported fd type error in json2msgpack (fixes #58) Borrowed the fix from here https://github.com/chjj/pty.js/issues/32#issuecomment-15322053 --- bin/json2msgpack | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/json2msgpack b/bin/json2msgpack index 72b04f7..12e3c0b 100755 --- a/bin/json2msgpack +++ b/bin/json2msgpack @@ -2,16 +2,16 @@ // Read JSON data from stdin and write MessagePack data to stdout. var msgpack = require('msgpack'); -var net = require('net'); +var tty = require('tty'); var data = ''; -var s = new net.Stream(0); +var s = new tty.ReadStream(0); s.addListener('data', function(d) { data += d; }); s.addListener('end', function() { - s = new net.Stream(1); + s = new tty.WriteStream(1); s.resume(); if (s.write(msgpack.pack(JSON.parse(data)))) { From cfca5a41958f9ab0aa8c5dad582308bf6a599f2d Mon Sep 17 00:00:00 2001 From: Dmitry Yakimenko Date: Thu, 14 Jul 2016 17:09:04 +0200 Subject: [PATCH 2/2] Fixed unsupported fd type error in msgpack2json Also fixes sys.puts deprecated warning (replaced with console.log). --- bin/msgpack2json | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bin/msgpack2json b/bin/msgpack2json index 1b3ff9d..80aff1d 100755 --- a/bin/msgpack2json +++ b/bin/msgpack2json @@ -2,12 +2,11 @@ // Read MessagePack data from stdin and write JSON data to stdout. var msgpack = require('msgpack'); -var net = require('net'); -var sys = require('sys'); +var tty = require('tty'); -var s = new net.Stream(0); +var s = new tty.ReadStream(0); s.addListener('data', function(b) { - sys.puts(JSON.stringify(msgpack.unpack(b))); + console.log(JSON.stringify(msgpack.unpack(b))); }); s.resume();