All files env.ts

31.57% Statements 6/19
100% Branches 0/0
0% Functions 0/4
31.57% Lines 6/19

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 271x 1x   1x       1x       1x           1x                  
import dotenv from "dotenv";
import z from "zod";
 
export function dev() {
  return process.env.NODE_ENV === "development";
}
 
export function prod() {
  return process.env.NODE_ENV === "production";
}
 
export function test() {
  return process.env.NODE_ENV === "test";
}
 
type Zod = typeof z;
 
export function defineEnv<T>(f: (z: Zod) => z.Schema<T>) {
  const schema = f(z);
  dotenv.config({ path: ".env" });
  if (process.env.NODE_ENV === "test") {
    dotenv.config({ path: ".env.test" });
  }
 
  return schema.parse(process.env);
}