-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bdb2c30
commit c1f56c1
Showing
3 changed files
with
29 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import ''; | ||
|
||
declare global { | ||
interface Window { | ||
// Available in Aerogel apps. | ||
$app?: { environment?: string }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,20 @@ | ||
export function isDevelopment(): boolean { | ||
return typeof process !== 'undefined' && process?.env?.NODE_ENV === 'development'; | ||
function getEnv(): string | null { | ||
if (typeof globalThis === 'object' && 'Cypress' in globalThis) { | ||
return 'testing'; | ||
} | ||
|
||
if (typeof window === 'object' && '$app' in window && !!window.$app?.environment) { | ||
return window.$app.environment; | ||
} | ||
|
||
if (typeof process === 'object' && process.env?.NODE_ENV) { | ||
return process.env.NODE_ENV; | ||
} | ||
|
||
return null; | ||
} | ||
export function applyStrictChecks(): boolean { | ||
const env = getEnv(); | ||
|
||
return env === 'development' || env === 'testing'; | ||
} |