Skip to content

Instantly share code, notes, and snippets.

@maks
Created April 10, 2012 04:03
Show Gist options
  • Save maks/2348249 to your computer and use it in GitHub Desktop.
Save maks/2348249 to your computer and use it in GitHub Desktop.
basic json pretty printing for cli
#!/usr/bin/env node
var pd = require('pretty-data').pd;
var buf = "";
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk) {
//process.stdout.write(chunk);
buf += chunk;
});
process.stdin.on('end', function () {
process.stdout.write(pd.json(buf)+'\n');
process.exit(0);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment