Skip to content

Commit

Permalink
fix: cli json output
Browse files Browse the repository at this point in the history
  • Loading branch information
remy committed Nov 17, 2017
1 parent a02b252 commit 39569c1
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 15 deletions.
11 changes: 9 additions & 2 deletions bin/cli-handle.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const parse = require('querystring').parse;
const resolveURL = require('url').resolve;
const jsome = require('jsome');
const highlight = require('cli-highlight').highlight;
const request = require('request');
const host =
process.env.HOST || process.env.JSONBIN_HOST || 'https://jsonbin.org';
Expand Down Expand Up @@ -105,6 +105,13 @@ module.exports = (args, settings, body) => {
return res;
}

return jsome.getColoredString(res);
res = JSON.stringify(res, '', 2);

if (process.stdout.isTTY) {
// if not being piped
return highlight(res, { language: 'json' });
}

return res;
});
};
65 changes: 54 additions & 11 deletions bin/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions bin/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jsonbin",
"readme": "README",
"version": "1.4.0",
"version": "1.4.1",
"description": "CLI and package for jsonbin.org",
"main": "index.js",
"bin": {
Expand All @@ -20,8 +20,8 @@
},
"dependencies": {
"babel-runtime": "^6.20.0",
"cli-highlight": "^1.1.4",
"clite": "^0.3.0",
"jsome": "^2.3.26",
"request": "^2.83.0"
},
"devDependencies": {
Expand Down

0 comments on commit 39569c1

Please sign in to comment.