diff options
author | Elizabeth Alexander Hunt <me@liz.coffee> | 2025-05-18 22:54:15 -0700 |
---|---|---|
committer | Elizabeth Alexander Hunt <me@liz.coffee> | 2025-05-18 22:55:20 -0700 |
commit | d54e91c6582ed160cf2f2fcf977e48b4439d133b (patch) | |
tree | 5669367c4fa49bc0373b0c581ea3027218fd5e32 /u/process/env.ts | |
parent | 9cf3fc0259730b7dcf47b3ab4a04369e39fb4614 (diff) | |
download | ci-theBigRefactor.tar.gz ci-theBigRefactor.zip |
snapshottheBigRefactor
Diffstat (limited to 'u/process/env.ts')
-rw-r--r-- | u/process/env.ts | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/u/process/env.ts b/u/process/env.ts index 26e1158..65f4e63 100644 --- a/u/process/env.ts +++ b/u/process/env.ts @@ -10,3 +10,18 @@ export const getRequiredEnv = (name: string): IEither<Error, string> => new Error(`environment variable "${name}" is required D:`), ) ); + +export const getRequiredEnvVars = (vars: Array<string>) => + vars + .map((envVar) => + [envVar, getRequiredEnv(envVar)] as [string, IEither<Error, string>] + ) + .reduce((acc, x: [string, IEither<Error, string>]) => { + const [envVar, eitherVal] = x; + return acc.flatMap((args) => { + return eitherVal.mapRight((envValue) => ({ + ...args, + [envVar]: envValue, + })); + }); + }, Either.right<Error, Record<string, string>>({})); |