Skip to content

Commit

Permalink
Tweak dev env detection (#1044)
Browse files Browse the repository at this point in the history
ALL-3453: tweak dev env detection

Co-authored-by: Filip Kaštovský <[email protected]>
  • Loading branch information
filipkastovsky and Filip Kaštovský authored Jan 9, 2024
1 parent 972925f commit 43dfdb1
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 13 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
## [4.2.1] - 2024.1.9

### Updated

- Assert development environment if `NODE_ENV` is not set

### Fixed

- Use globalThis instead of `process.env` for setting `TatumDevelopmentLogger`'s `isWelcomeDisabled` flag

## [4.2.0] - 2024.1.8

### Added

- Added logging support

### Updated

- Updated dependencies

## [4.1.37] - 2024.1.5
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tatumio/tatum",
"version": "4.2.0",
"version": "4.2.1",
"description": "Tatum JS SDK",
"author": "Tatum",
"repository": "https://github.com/tatumio/tatum-js",
Expand Down
10 changes: 5 additions & 5 deletions src/service/logger/logger.development.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ interface TatumDevelopmentLoggerOptions {
}

export class TatumDevelopmentLogger implements Logger {
private static readonly DISABLE_WELCOME = 'TTM_DISABLE_WELCOME'
private static readonly DISABLE_WELCOME = '__TTM_DISABLE_WELCOME__'
private static isWelcomeDisabled(): boolean {
if (!EnvUtils.isProcessAvailable()) return false
return process.env[TatumDevelopmentLogger.DISABLE_WELCOME] === 'true'
const anyGlobal = globalThis as unknown as { __TTM_DISABLE_WELCOME__: boolean }
return !!anyGlobal[TatumDevelopmentLogger.DISABLE_WELCOME]
}

private static disableWelcome(): void {
if (!EnvUtils.isProcessAvailable()) return
process.env[TatumDevelopmentLogger.DISABLE_WELCOME] = 'true'
const anyGlobal = globalThis as unknown as { __TTM_DISABLE_WELCOME__: boolean }
anyGlobal[TatumDevelopmentLogger.DISABLE_WELCOME] = true
}

private readonly options: TatumDevelopmentLoggerOptions
Expand Down
2 changes: 1 addition & 1 deletion src/util/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ export const EnvUtils = {
isBrowser: () => typeof window !== 'undefined',
isProcessAvailable: () => typeof process !== 'undefined',
isDevelopment: () =>
(EnvUtils.isProcessAvailable() && process?.env?.NODE_ENV === 'development') ||
(EnvUtils.isProcessAvailable() && (!process.env?.NODE_ENV || process.env?.NODE_ENV === 'development')) ||
(EnvUtils.isBrowser() && ['localhost', '127.0.0.1', '[::1]'].includes(window.location.hostname)),
}
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@
integrity sha512-85ttAOMLsr53VgXkTbkx8oA6YTfT4q7/HzXSLEYmjcSTJPMPQtvq1BD79Byep5xMUYbGRzEpDsjUf3dyp54IKw==

"@babel/helpers@^7.23.7":
version "7.23.7"
resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.23.7.tgz#eb543c36f81da2873e47b76ee032343ac83bba60"
integrity sha512-6AMnjCoC8wjqBzDHkuqpa7jAKwvMo4dC+lr/TFBz+ucfulO1XMpDnwWPGBNwClOKZ8h6xn5N81W/R5OrcKtCbQ==
version "7.23.8"
resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.23.8.tgz#fc6b2d65b16847fd50adddbd4232c76378959e34"
integrity sha512-KDqYz4PiOWvDFrdHLPhKtCThtIcKVy6avWD2oG4GEvyQ+XDZwHD4YQd+H2vNMnq2rkdxsDkU82T+Vk8U/WXHRQ==
dependencies:
"@babel/template" "^7.22.15"
"@babel/traverse" "^7.23.7"
Expand Down Expand Up @@ -1264,9 +1264,9 @@ dotenv@^16.0.3:
integrity sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==

electron-to-chromium@^1.4.601:
version "1.4.623"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.623.tgz#0f7400114ac3425500e9244d2b0e9c3107c331cb"
integrity sha512-lKoz10iCYlP1WtRYdh5MvocQPWVRoI7ysp6qf18bmeBgR8abE6+I2CsfyNKztRDZvhdWc+krKT6wS7Neg8sw3A==
version "1.4.625"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.625.tgz#a9a1d18ee911f9074a9c42d9e84b1c79b29f4059"
integrity sha512-DENMhh3MFgaPDoXWrVIqSPInQoLImywfCwrSmVl3cf9QHzoZSiutHwGaB/Ql3VkqcQV30rzgdM+BjKqBAJxo5Q==

emittery@^0.13.1:
version "0.13.1"
Expand Down

0 comments on commit 43dfdb1

Please sign in to comment.