Use @medv/prettyjson

js-version
Anton Medvedev 6 years ago
parent 51bb5d9725
commit abd80a935d

@ -31,7 +31,7 @@ Pretty print JSON without passing any arguments:
``` ```
$ echo '{"key":"value"}' | fx $ echo '{"key":"value"}' | fx
{ {
"key": "value" "key": "value"
} }
``` ```
@ -72,17 +72,17 @@ Access to JSON through `this` keyword:
``` ```
$ echo '["a", "b"]' | fx 'yield* this' $ echo '["a", "b"]' | fx 'yield* this'
[ [
"a", "a",
"b" "b"
] ]
``` ```
``` ```
$ echo '["a", "b"]' | fx 'yield* this; yield "c";' $ echo '["a", "b"]' | fx 'yield* this; yield "c";'
[ [
"a", "a",
"b", "b",
"c" "c"
] ]
``` ```
@ -93,7 +93,7 @@ You can update existing JSON using spread operator:
``` ```
$ echo '{"count": 0}' | fx '{...this, count: 1}' $ echo '{"count": 0}' | fx '{...this, count: 1}'
{ {
"count": 1 "count": 1
} }
``` ```
@ -125,9 +125,9 @@ Convert object to array:
``` ```
$ cat package.json | fx 'Object.keys(this.dependencies)' $ cat package.json | fx 'Object.keys(this.dependencies)'
[ [
"get-stdin", "@medv/prettyjson",
"jsome", "get-stdin",
"meow" "meow"
] ]
``` ```

@ -2,7 +2,7 @@
'use strict' 'use strict'
const meow = require('meow') const meow = require('meow')
const stdin = require('get-stdin') const stdin = require('get-stdin')
const jsome = require('jsome') const pretty = require('@medv/prettyjson')
const cli = meow(` const cli = meow(`
Usage Usage
@ -35,7 +35,7 @@ async function main() {
if (typeof result === 'undefined') { if (typeof result === 'undefined') {
process.stderr.write('undefined\n') process.stderr.write('undefined\n')
} else if (process.stdout.isTTY) { } else if (process.stdout.isTTY) {
jsome(result) console.log(pretty(result))
} else { } else {
console.log(JSON.stringify(result, null, 2)) console.log(JSON.stringify(result, null, 2))
} }

@ -23,13 +23,13 @@
"node": ">=8" "node": ">=8"
}, },
"dependencies": { "dependencies": {
"get-stdin": "^5.0.1", "@medv/prettyjson": "^1.0.0",
"jsome": "^2.5.0", "get-stdin": "^6.0.0",
"meow": "^4.0.0" "meow": "^5.0.0"
}, },
"devDependencies": { "devDependencies": {
"ava": "^0.24.0", "ava": "^0.25.0",
"pkg": "^4.3.0", "pkg": "^4.3.3",
"release-it": "^6.1.1" "release-it": "^7.4.7"
} }
} }

Loading…
Cancel
Save