Skip to content

Commit

Permalink
nicer json output
Browse files Browse the repository at this point in the history
  • Loading branch information
konsumer committed Jul 30, 2021
1 parent a79ad83 commit 1d7792b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/tplight.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const TPLSmartDevice = require('../dist/tplink-lightbulb.cjs')
const yargs = require('yargs')
const util = require('util')

// https://gist.github.com/xenozauros/f6e185c8de2a04cdfecf
function hexToHsl (hex) {
Expand Down Expand Up @@ -37,7 +36,8 @@ async function readStream (stream = process.stdin) {
})
}

const json = process.stdout.isTTY ? s => console.log(util.inspect(s, false, null, true)) : s => console.log(JSON.stringify(s, null, 2))
// wrapper that will output JSON or colored depending on how it's being piped
const json = process.stdout.isTTY ? s => console.dir(s, { depth: null, colors: true, maxArrayLength: null, maxStringLength: null }) : s => console.log(JSON.stringify(s, null, 2))

// for pkg support
if (typeof process.pkg !== 'undefined') {
Expand Down

0 comments on commit 1d7792b

Please sign in to comment.