From 2e1b65703a607eb2cd66e8f981547037321da07a Mon Sep 17 00:00:00 2001 From: Varun0157 Date: Tue, 28 May 2024 00:09:38 +0530 Subject: [PATCH] refactor: reducing nesting in getBundleVars and formatting w prettier --- src/variableParser.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/variableParser.ts b/src/variableParser.ts index 33ea8ec..53a619d 100644 --- a/src/variableParser.ts +++ b/src/variableParser.ts @@ -30,14 +30,12 @@ export function getBundleVariables(doc: string | undefined): Variables { throw new Error("Bundle could not be parsed. Is your bundle a valid YAML document?"); const variables = parsedData.variables; - if (variables !== undefined) { - const error = checkVariables(variables); - if (error !== undefined) throw new Error(`error in variables: ${error}`); + if (variables === undefined) return {}; - return variables; - } else { - return {}; - } + const error = checkVariables(variables); + if (error !== undefined) throw new Error(`error in variables: ${error}`); + + return variables; } export function getEnvironments(bundleContent: string | undefined, varFileContents: string[]): string[] { @@ -58,7 +56,7 @@ export function getEnvironments(bundleContent: string | undefined, varFileConten export function loadVariables( envName: string | undefined, bundleContent: string | undefined, - varFileContents: string[] + varFileContents: string[], ): Variables { if (!envName) return {};