Created
January 14, 2016 16:53
-
-
Save jpmens/f4d8819b0d4a0821c0f3 to your computer and use it in GitHub Desktop.
patch wscat to display pretty JSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*** /usr/local/bin/wscat.orig 2016-01-14 17:47:00.000000000 +0100 | |
--- /usr/local/bin/wscat 2016-01-14 17:51:37.000000000 +0100 | |
*************** | |
*** 211,217 **** | |
wsConsole.print('error: ' + code + (description ? ' ' + description : ''), Console.Colors.Yellow); | |
process.exit(-1); | |
}).on('message', function message(data, flags) { | |
! wsConsole.print('< ' + data, Console.Colors.Blue); | |
}); | |
wsConsole.on('close', function close() { | |
--- 211,223 ---- | |
wsConsole.print('error: ' + code + (description ? ' ' + description : ''), Console.Colors.Yellow); | |
process.exit(-1); | |
}).on('message', function message(data, flags) { | |
! var s; | |
! try { | |
! s = JSON.stringify(JSON.parse(data), null, 4); | |
! } catch (e) { | |
! s = data; | |
! } | |
! wsConsole.print('< ' + s, Console.Colors.Blue); | |
}); | |
wsConsole.on('close', function close() { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cool! would you make a PR on wscat repo? Enabled this with a flag would be awesome.