From a6109060ed7ea45c107ee2c076165d023fc4a835 Mon Sep 17 00:00:00 2001 From: farfromrefuge Date: Thu, 7 Dec 2023 22:17:10 +0100 Subject: [PATCH] feat: add --json option to `ns config` --- lib/commands/config.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/commands/config.ts b/lib/commands/config.ts index 80839a1cfa..47e778b179 100644 --- a/lib/commands/config.ts +++ b/lib/commands/config.ts @@ -4,19 +4,25 @@ import { IProjectConfigService } from "../definitions/project"; import { SupportedConfigValues } from "../tools/config-manipulation/config-transformer"; import { IErrors } from "../common/declarations"; import { color } from "../color"; +import { IOptions } from "../declarations"; export class ConfigListCommand implements ICommand { public allowedParameters: ICommandParameter[] = []; constructor( private $projectConfigService: IProjectConfigService, + private $options: IOptions, private $logger: ILogger ) {} public async execute(args: string[]): Promise { try { const config = this.$projectConfigService.readConfig(); - this.$logger.info(this.getValueString(config as SupportedConfigValues)); + if (this.$options.json) { + console.log(JSON.stringify(config)) + } else { + this.$logger.info(this.getValueString(config as SupportedConfigValues)); + } } catch (error) { this.$logger.info("Failed to read config. Error is: ", error); }