From c83fce16dcd51d5894f52d006134024a58062c12 Mon Sep 17 00:00:00 2001 From: Mirko Golze Date: Fri, 22 Sep 2023 09:22:46 +0200 Subject: [PATCH] #199 small code refactoring --- packages/bruno-cli/src/commands/run.js | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/packages/bruno-cli/src/commands/run.js b/packages/bruno-cli/src/commands/run.js index 45643ea5..420eb696 100644 --- a/packages/bruno-cli/src/commands/run.js +++ b/packages/bruno-cli/src/commands/run.js @@ -183,18 +183,17 @@ const handler = async function (argv) { } if (envVar) { + let processVars; if (typeof envVar === 'string') { - let parts = envVar.split('='); - if (parts.length !== 2) { - console.error( - chalk.red(`overridable environment variable not correct: use name=value - presented: `) + - chalk.dim(`${envVar}`) - ); - return; - } - envVars[parts[0]] = parts[1]; + processVars = [envVar]; } else if (typeof envVar === 'object' && Array.isArray(envVar)) { - envVar.forEach((value) => { + processVars = envVar; + } else { + console.error(chalk.red(`overridable environment variables not parsable: use name=value`)); + return; + } + if (processVars && Array.isArray(processVars)) { + processVars.forEach((value) => { let parts = value.split('='); if (parts.length !== 2) { console.error( @@ -205,9 +204,6 @@ const handler = async function (argv) { } envVars[parts[0]] = parts[1]; }); - } else { - console.error(chalk.red(`overridable environment variables not parsable: use name=value`)); - return; } }