From c0a4bb78e99ea4070fd9387a1bac3ed4f702ef91 Mon Sep 17 00:00:00 2001 From: knidarkness Date: Mon, 30 Sep 2019 12:15:21 +0300 Subject: [PATCH] removed redundant variable --- cli/index.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/cli/index.ts b/cli/index.ts index 1b48635c..5c02a6f3 100644 --- a/cli/index.ts +++ b/cli/index.ts @@ -64,14 +64,12 @@ YargsParser.command( return yargs; }, async argv => { - const redocOptions = getRedocOptions(argv.options); - const config: Options = { ssr: argv.ssr as boolean, watch: argv.watch as boolean, templateFileName: argv.template as string, templateOptions: argv.templateOptions || {}, - redocOptions, + redocOptions: getObjectOrJSON(argv.options), }; console.log(config); @@ -120,8 +118,6 @@ YargsParser.command( return yargs; }, async (argv: any) => { - const redocOptions = getRedocOptions(argv.options); - const config = { ssr: true, output: argv.o as string, @@ -130,7 +126,7 @@ YargsParser.command( disableGoogleFont: argv.disableGoogleFont as boolean, templateFileName: argv.template as string, templateOptions: argv.templateOptions || {}, - redocOptions, + redocOptions: getObjectOrJSON(argv.options), }; try { @@ -360,9 +356,9 @@ function handleError(error: Error) { process.exit(1); } -function getRedocOptions(options) { +function getObjectOrJSON(options) { return options && typeof options === 'string' ? JSON.parse(options) : options ? options : {}; -} \ No newline at end of file +}