#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) {
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}`)
);
processVars = [envVar];
} else if (typeof envVar === 'object' && Array.isArray(envVar)) {
processVars = envVar;
} else {
console.error(chalk.red(`overridable environment variables not parsable: use name=value`));
return;
}
envVars[parts[0]] = parts[1];
} else if (typeof envVar === 'object' && Array.isArray(envVar)) {
envVar.forEach((value) => {
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;
}
}