summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElizabeth Hunt <lizhunt@amazon.com>2025-05-13 18:58:45 -0700
committerElizabeth Hunt <lizhunt@amazon.com>2025-05-14 18:03:14 -0700
commitf316b4a015b5b2e2988b250b3c34bbb7f9994709 (patch)
tree1ef7bafcc33a2e6b5d2c9bdc374af68135d3f07e
parent1d66a0f58e4ebcdf4f42c9d78f82a1ab49a2cf11 (diff)
downloadci-f316b4a015b5b2e2988b250b3c34bbb7f9994709.tar.gz
ci-f316b4a015b5b2e2988b250b3c34bbb7f9994709.zip
snapshot!
-rw-r--r--u/process/env.ts16
1 files changed, 9 insertions, 7 deletions
diff --git a/u/process/env.ts b/u/process/env.ts
index e80ec4a..c3ae800 100644
--- a/u/process/env.ts
+++ b/u/process/env.ts
@@ -1,10 +1,12 @@
import { Either, type IEither } from "@emprespresso/utils";
export const getRequiredEnv = (name: string): IEither<Error, string> =>
- Either.fromFailable(() => {
- const value = Deno.env.get(name); // could throw when no permission.
- if (!value) {
- throw new Error(`environment variable "${name}" is required D:`);
- }
- return value;
- });
+ Either
+ .fromFailable<Error, string | undefined>(() => Deno.env.get(name)) // could throw when no permission.
+ .flatMap((v) =>
+ (v &&
+ Either.right(v)) ||
+ Either.left(
+ new Error(`environment variable "${name}" is required D:`),
+ )
+ );