#199 small code refactoring

This commit is contained in:
Mirko Golze 2023-09-22 09:22:46 +02:00
parent 74282706aa
commit 6b9e085696

View File

@ -183,18 +183,17 @@ const handler = async function (argv) {
} }
if (envVar) { if (envVar) {
let processVars;
if (typeof envVar === 'string') { if (typeof envVar === 'string') {
let parts = envVar.split('='); processVars = [envVar];
if (parts.length !== 2) { } else if (typeof envVar === 'object' && Array.isArray(envVar)) {
console.error( processVars = envVar;
chalk.red(`overridable environment variable not correct: use name=value - presented: `) + } else {
chalk.dim(`${envVar}`) console.error(chalk.red(`overridable environment variables not parsable: use name=value`));
);
return; return;
} }
envVars[parts[0]] = parts[1]; if (processVars && Array.isArray(processVars)) {
} else if (typeof envVar === 'object' && Array.isArray(envVar)) { processVars.forEach((value) => {
envVar.forEach((value) => {
let parts = value.split('='); let parts = value.split('=');
if (parts.length !== 2) { if (parts.length !== 2) {
console.error( console.error(
@ -205,9 +204,6 @@ const handler = async function (argv) {
} }
envVars[parts[0]] = parts[1]; envVars[parts[0]] = parts[1];
}); });
} else {
console.error(chalk.red(`overridable environment variables not parsable: use name=value`));
return;
} }
} }