• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yiming-liao / logry / 16014399996

02 Jul 2025 02:07AM UTC coverage: 92.485% (-0.3%) from 92.796%
16014399996

push

github

yiming-liao
chore(release): bump version to 1.1.3

442 of 499 branches covered (88.58%)

Branch coverage included in aggregate %.

4210 of 4531 relevant lines covered (92.92%)

4.34 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

69.77
/src/shared/utils/is-dev-mode.ts
1
/* eslint-disable @typescript-eslint/no-explicit-any */
1✔
2

1✔
3
import { isNode } from "@/shared/utils/is-node";
1✔
4

1✔
5
/**
1✔
6
 * Detects if the current runtime environment is in development mode.
1✔
7
 *
1✔
8
 * In Node.js, it checks the NODE_ENV environment variable:
1✔
9
 * - If NODE_ENV is set, returns true unless it's 'production'.
1✔
10
 * - If NODE_ENV is undefined, defaults to development mode (true).
1✔
11
 *
1✔
12
 * In browsers, it checks the global `__LOGRY_DEV__` flag:
1✔
13
 * - Returns true if `__LOGRY_DEV__` is explicitly set to a truthy value.
1✔
14
 * - Defaults to production mode (false) if the flag is undefined.
1✔
15
 *
1✔
16
 * This design assumes Node defaults to development for ease of local testing,
1✔
17
 * while browsers default to production to avoid unnecessary debug logs.
1✔
18
 *
1✔
19
 * @returns boolean indicating if running in development mode
1✔
20
 */
1✔
21
export const isDevMode = (): boolean => {
1✔
22
  if (isNode()) {
2✔
23
    // Check NODE_ENV in Node
2✔
24
    const nodeEnv =
2✔
25
      process?.env?.NODE_ENV ?? (globalThis as any).process?.env?.NODE_ENV;
2!
26

2✔
27
    if (typeof nodeEnv === "string") {
2✔
28
      return nodeEnv !== "production";
2✔
29
    }
2✔
30
    return true; // Assume dev if NODE_ENV is undefined
×
31
  }
×
32

×
33
  // Browser fallback via global flag
×
34
  if (typeof (globalThis as any).__LOGRY_DEV__ !== "undefined") {
×
35
    return Boolean((globalThis as any).__LOGRY_DEV__);
×
36
  }
×
37

×
38
  // Default fallback
×
39
  return false;
×
40
};
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc