From 8667a47d445dc8eac57c307700d65a679a3d4993 Mon Sep 17 00:00:00 2001 From: Jari Kolehmainen Date: Thu, 22 Dec 2022 16:22:59 +0200 Subject: [PATCH] remove NODE_ENV from environmentVariablesInjectable Signed-off-by: Jari Kolehmainen --- src/common/utils/environment-variables.injectable.ts | 7 +------ src/common/vars/is-production.injectable.ts | 4 ++-- ...eveloper-tools-in-development-environment.injectable.ts | 4 +++- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/common/utils/environment-variables.injectable.ts b/src/common/utils/environment-variables.injectable.ts index e820312f81..899d012f78 100644 --- a/src/common/utils/environment-variables.injectable.ts +++ b/src/common/utils/environment-variables.injectable.ts @@ -3,21 +3,16 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import nodeEnvInjectionToken from "../vars/node-env-injection-token"; const environmentVariablesInjectable = getInjectable({ id: "environment-variables", - instantiate: (di) => { - // IMPORTANT: The syntax needs to be exactly this in order to make environment variable values - // hard-coded at compile-time by Webpack. - const NODE_ENV = di.inject(nodeEnvInjectionToken); + instantiate: () => { const JEST_WORKER_ID = process.env.JEST_WORKER_ID; const CICD = process.env.CICD; return { // Compile-time environment variables - NODE_ENV, JEST_WORKER_ID, CICD, diff --git a/src/common/vars/is-production.injectable.ts b/src/common/vars/is-production.injectable.ts index 085b091dfa..661cb397d1 100644 --- a/src/common/vars/is-production.injectable.ts +++ b/src/common/vars/is-production.injectable.ts @@ -3,13 +3,13 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import environmentVariablesInjectable from "../utils/environment-variables.injectable"; +import nodeEnvInjectionToken from "./node-env-injection-token"; const isProductionInjectable = getInjectable({ id: "is-production", instantiate: (di) => { - const { NODE_ENV: nodeEnv } = di.inject(environmentVariablesInjectable); + const nodeEnv = di.inject(nodeEnvInjectionToken); return nodeEnv === "production"; }, diff --git a/src/main/electron-app/runnables/setup-developer-tools-in-development-environment.injectable.ts b/src/main/electron-app/runnables/setup-developer-tools-in-development-environment.injectable.ts index 07807a7965..5572887b06 100644 --- a/src/main/electron-app/runnables/setup-developer-tools-in-development-environment.injectable.ts +++ b/src/main/electron-app/runnables/setup-developer-tools-in-development-environment.injectable.ts @@ -3,6 +3,7 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; +import nodeEnvInjectionToken from "../../../common/vars/node-env-injection-token"; import loggerInjectable from "../../../common/logger.injectable"; import { onLoadOfApplicationInjectionToken } from "../../start-main-application/runnable-tokens/on-load-of-application-injection-token"; @@ -11,11 +12,12 @@ const setupDeveloperToolsInDevelopmentEnvironmentInjectable = getInjectable({ instantiate: (di) => { const logger = di.inject(loggerInjectable); + const nodeEnv = di.inject(nodeEnvInjectionToken); return { id: "setup-developer-tools-in-development-environment", run: () => { - if (process.env.NODE_ENV !== "development") { + if (nodeEnv !== "development") { return; }