From 59e658d8a32a61edb7895a2fcdbe3aa9d9a10c0e Mon Sep 17 00:00:00 2001 From: Florian Schmidt <31537961+Florian7843@users.noreply.github.com> Date: Sun, 12 Sep 2021 15:47:28 +0200 Subject: [PATCH] Fix/formatted (#10) * fix(classicLambda): updated classicLambda model * chore(todo): for command output * build(debug): added model parameter to launch.json * refactor(model): minor changes to classicLambda * fix(parse): added ability to parse arrays * docs(models): added classicLambda documentation * refactor(hargassnerTelnet): removed unnessacary import * fix(formatted): formattet output not showing [object] anymore --- src/bin/hgjson.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bin/hgjson.ts b/src/bin/hgjson.ts index c32db72..de83cdb 100755 --- a/src/bin/hgjson.ts +++ b/src/bin/hgjson.ts @@ -86,13 +86,13 @@ client.on('data', (data) => { array = Object.assign({}, array) } - string = argv.formatted ? array : JSON.stringify(array) + string = JSON.stringify(array, null, argv.formatted ? 2 : 0) } else { // --array option is not specified - // TODO: output data formatted via JSON.strigify(data, null, 2) as output shows [object] - // if formatted or raw is set output data as is, otherwise stringify - string = argv.formatted || argv.raw ? data : JSON.stringify(data) + // if --raw, then output as is, otherwise stringify. if --formatted then intent otherwise don't + if (argv.raw) string = data + else string = JSON.stringify(data, null, argv.formatted ? 2 : 0) } console.log(string)