Skip to content

Commit

Permalink
Merging fb651e2 into trunk-temp/pr-3012/12376ff6-36fd-457c-8e04-22f96…
Browse files Browse the repository at this point in the history
…8794bf2
  • Loading branch information
trunk-io[bot] authored Jan 30, 2025
2 parents a9af1e4 + fb651e2 commit a75560f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion env/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export type Env = {
[key: string]: unknown;
FLY_APP_NAME?: string;
VERCEL?: string;
MODE?: string;
NODE_ENV?: string;
ARCJET_KEY?: string;
ARCJET_ENV?: string;
Expand All @@ -20,7 +21,11 @@ export function platform(env: Env) {
}

export function isDevelopment(env: Env) {
return env.NODE_ENV === "development" || env.ARCJET_ENV === "development";
return (
env.NODE_ENV === "development" ||
env.MODE === "development" ||
env.ARCJET_ENV === "development"
);
}

export function logLevel(env: Env) {
Expand Down
4 changes: 4 additions & 0 deletions env/test/env.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ describe("env", () => {
expect(env.platform({})).toBeUndefined();
expect(env.platform({ FLY_APP_NAME: "" })).toBeUndefined();
expect(env.platform({ FLY_APP_NAME: "foobar" })).toEqual("fly-io");
expect(env.platform({ VERCEL: "" })).toBeUndefined();
expect(env.platform({ VERCEL: "1" })).toEqual("vercel");
});

test("isDevelopment", () => {
expect(env.isDevelopment({})).toEqual(false);
expect(env.isDevelopment({ NODE_ENV: "production" })).toEqual(false);
expect(env.isDevelopment({ NODE_ENV: "development" })).toEqual(true);
expect(env.isDevelopment({ MODE: "production" })).toEqual(false);
expect(env.isDevelopment({ MODE: "development" })).toEqual(true);
expect(env.isDevelopment({ ARCJET_ENV: "production" })).toEqual(false);
expect(env.isDevelopment({ ARCJET_ENV: "development" })).toEqual(true);
});
Expand Down
3 changes: 2 additions & 1 deletion turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"ARCJET_RUNTIME",
"ARCJET_LOG_LEVEL",
"OPENAI_API_KEY",
"FLY_APP_NAME"
"FLY_APP_NAME",
"MODE"
],
"tasks": {
"build": {
Expand Down

0 comments on commit a75560f

Please sign in to comment.