From 92b755ac7870d05e779cad4403031187a0fd3e2f Mon Sep 17 00:00:00 2001 From: kurone-kito Date: Thu, 6 May 2021 16:13:15 +0900 Subject: [PATCH] refactor: splited the JSON renderer --- packages/dantalion-cli/src/index.ts | 5 +---- packages/dantalion-cli/src/render/showJson.ts | 7 +++++++ 2 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 packages/dantalion-cli/src/render/showJson.ts diff --git a/packages/dantalion-cli/src/index.ts b/packages/dantalion-cli/src/index.ts index 7ca0d05..68555ec 100644 --- a/packages/dantalion-cli/src/index.ts +++ b/packages/dantalion-cli/src/index.ts @@ -4,10 +4,7 @@ import commander from 'commander'; import { version } from '../package.json'; import detail from './detail'; import personality from './personality'; - -const showJson = (result: unknown) => - // eslint-disable-next-line no-console - console.info(JSON.stringify(result, null, 2)); +import showJson from './render/showJson'; [detail, personality].forEach(({ action, alias, command, description }) => { commander diff --git a/packages/dantalion-cli/src/render/showJson.ts b/packages/dantalion-cli/src/render/showJson.ts new file mode 100644 index 0000000..5c67bf9 --- /dev/null +++ b/packages/dantalion-cli/src/render/showJson.ts @@ -0,0 +1,7 @@ +/** + * Render the object to JSON. + * @param result The object. + */ +export default (result: unknown): void => + // eslint-disable-next-line no-console + console.info(JSON.stringify(result, null, 2));