( rawEnvArgs: string[] | undefined, )
| 70 | * @returns Object with key-value pairs |
| 71 | */ |
| 72 | export function parseEnvVars( |
| 73 | rawEnvArgs: string[] | undefined, |
| 74 | ): Record<string, string> { |
| 75 | const parsedEnv: Record<string, string> = {} |
| 76 | |
| 77 | // Parse individual env vars |
| 78 | if (rawEnvArgs) { |
| 79 | for (const envStr of rawEnvArgs) { |
| 80 | const [key, ...valueParts] = envStr.split('=') |
| 81 | if (!key || valueParts.length === 0) { |
| 82 | throw new Error( |
| 83 | `Invalid environment variable format: ${envStr}, environment variables should be added as: -e KEY1=value1 -e KEY2=value2`, |
| 84 | ) |
| 85 | } |
| 86 | parsedEnv[key] = valueParts.join('=') |
| 87 | } |
| 88 | } |
| 89 | return parsedEnv |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * Get the AWS region with fallback to default |
no outgoing calls
no test coverage detected