Deprecate another var with injectable

Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com>

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne SavolainenandMikko Aspiala committed 2022-05-11 08:25:35 +03:00
1 parent d93080b4e5
commit 579dfd2d0b
3 files changed
+24 -3

No files matched your search

+4
View File
@@ -26,6 +26,10 @@ export const isLinux = process.platform === "linux";
export const isDebugging = ["true", "1", "yes", "y", "on"].includes((process.env.DEBUG ?? "").toLowerCase());
export const isSnap = !!process.env.SNAP;
/**
* @deprecated Switch to using isTestEnvInjectable
*/
export const isTestEnv = !!process.env.JEST_WORKER_ID;
/**
+2 -3
View File
@@ -3,19 +3,18 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import { isTestEnv } from "../vars";
import isProductionInjectable from "./is-production.injectable";
import isTestEnvInjectable from "./is-test-env.injectable";
const isDevelopmentInjectable = getInjectable({
id: "is-development",
instantiate: (di) => {
const isProduction = di.inject(isProductionInjectable);
const isTestEnv = di.inject(isTestEnvInjectable);
return !isTestEnv && !isProduction;
},
causesSideEffects: true,
});
export default isDevelopmentInjectable;
+18
View File
@@ -0,0 +1,18 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* 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";
const isTestEnvInjectable = getInjectable({
id: "is-test-env",
instantiate: (di) => {
const { JEST_WORKER_ID: jestWorkerId } = di.inject(environmentVariablesInjectable);
return !!jestWorkerId;
},
});
export default isTestEnvInjectable;