github.com/henvic/wedeploycli@v1.7.6-0.20200319005353-3630f582f284/prettyjson/prettyjson.go (about) 1 package prettyjson 2 3 import ( 4 "github.com/henvic/wedeploycli/color" 5 "github.com/henvic/wedeploycli/isterm" 6 "github.com/tidwall/pretty" 7 ) 8 9 // Pretty prettifies JSON 10 func Pretty(b []byte) []byte { 11 res := pretty.PrettyOptions(b, &pretty.Options{ 12 Width: 20, 13 Indent: " ", 14 }) 15 16 if !color.NoColor && isterm.Stderr() && isterm.Stdout() { 17 res = pretty.Color(res, nil) 18 } 19 20 return res 21 }