From 1aecfe0741d086232aad5d8e649f66f1e9698c43 Mon Sep 17 00:00:00 2001 From: Jon Edvald Date: Tue, 24 Apr 2018 13:28:03 +0200 Subject: [PATCH] fix: better output rendering for JSON responses in call command --- src/commands/call.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/commands/call.ts b/src/commands/call.ts index 16ebe4bb9e..1f6a0be2f7 100644 --- a/src/commands/call.ts +++ b/src/commands/call.ts @@ -9,6 +9,7 @@ import { resolve } from "url" import Axios from "axios" import chalk from "chalk" +import { isObject } from "util" import { Command, ParameterValues, StringParameter } from "./base" import { splitFirst } from "../util" import { ParameterError, RuntimeError } from "../exceptions" @@ -113,7 +114,9 @@ export class CallCommand extends Command { ctx.log.info(chalk.red(`\n${res.status} ${res.statusText}\n`)) } - res.data && ctx.log.info(chalk.white(res.data)) + const resStr = isObject(res.data) ? JSON.stringify(res.data, null, 2) : res.data + + res.data && ctx.log.info(chalk.white(resStr)) return { serviceName,