( rawEnvArgs: string[] | undefined, )
| 102 | * @returns Object with key-value pairs |
| 103 | */ |
| 104 | export function parseEnvVars( |
| 105 | rawEnvArgs: string[] | undefined, |
| 106 | ): Record<string, string> { |
| 107 | const parsedEnv: Record<string, string> = {} |
| 108 | |
| 109 | // Parse individual env vars |
| 110 | if (rawEnvArgs) { |
| 111 | for (const envStr of rawEnvArgs) { |
| 112 | const [key, ...valueParts] = envStr.split('=') |
| 113 | if (!key || valueParts.length === 0) { |
| 114 | throw new Error( |
| 115 | `Invalid environment variable format: ${envStr}, environment variables should be added as: -e KEY1=value1 -e KEY2=value2`, |
| 116 | ) |
| 117 | } |
| 118 | parsedEnv[key] = valueParts.join('=') |
| 119 | } |
| 120 | } |
| 121 | return parsedEnv |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Get the AWS region with fallback to default |
no outgoing calls
no test coverage detected