mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Adapt vars after merge
Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
parent
81ddf1153c
commit
a3f139a40d
@ -26,9 +26,13 @@ export const isLinux = process.platform === "linux";
|
|||||||
|
|
||||||
export const isDebugging = ["true", "1", "yes", "y", "on"].includes((process.env.DEBUG ?? "").toLowerCase());
|
export const isDebugging = ["true", "1", "yes", "y", "on"].includes((process.env.DEBUG ?? "").toLowerCase());
|
||||||
export const isSnap = !!process.env.SNAP;
|
export const isSnap = !!process.env.SNAP;
|
||||||
export const isProduction = process.env.NODE_ENV === "production";
|
|
||||||
export const isTestEnv = !!process.env.JEST_WORKER_ID;
|
export const isTestEnv = !!process.env.JEST_WORKER_ID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Switch to using isProductionInjectable
|
||||||
|
*/
|
||||||
|
export const isProduction = process.env.NODE_ENV === "production";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Switch to using isDevelopmentInjectable
|
* @deprecated Switch to using isDevelopmentInjectable
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -3,11 +3,18 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { isProduction, isTestEnv } from "../vars";
|
import { isTestEnv } from "../vars";
|
||||||
|
import isProductionInjectable from "./is-production.injectable";
|
||||||
|
|
||||||
const isDevelopmentInjectable = getInjectable({
|
const isDevelopmentInjectable = getInjectable({
|
||||||
id: "is-development",
|
id: "is-development",
|
||||||
instantiate: () => !isTestEnv && !isProduction,
|
|
||||||
|
instantiate: (di) => {
|
||||||
|
const isProduction = di.inject(isProductionInjectable);
|
||||||
|
|
||||||
|
return !isTestEnv && !isProduction;
|
||||||
|
},
|
||||||
|
|
||||||
causesSideEffects: true,
|
causesSideEffects: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
18
src/common/vars/is-production.injectable.ts
Normal file
18
src/common/vars/is-production.injectable.ts
Normal 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 isProductionInjectable = getInjectable({
|
||||||
|
id: "is-production",
|
||||||
|
|
||||||
|
instantiate: (di) => {
|
||||||
|
const { NODE_ENV: nodeEnv } = di.inject(environmentVariablesInjectable);
|
||||||
|
|
||||||
|
return nodeEnv === "production";
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default isProductionInjectable;
|
||||||
@ -3,22 +3,20 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import contextDirInjectable from "./context-dir.injectable";
|
import isProductionInjectable from "./is-production.injectable";
|
||||||
import isDevelopmentInjectable from "./is-development.injectable";
|
|
||||||
|
|
||||||
const lensResourcesDirInjectable = getInjectable({
|
const lensResourcesDirInjectable = getInjectable({
|
||||||
id: "lens-resources-dir",
|
id: "lens-resources-dir",
|
||||||
|
|
||||||
instantiate: (di) => {
|
instantiate: (di) => {
|
||||||
const isDevelopment = di.inject(isDevelopmentInjectable);
|
const isProduction = di.inject(isProductionInjectable);
|
||||||
const contextDir = di.inject(contextDirInjectable);
|
|
||||||
|
|
||||||
return isDevelopment
|
return !isProduction
|
||||||
? contextDir
|
? process.cwd()
|
||||||
: (process.resourcesPath ?? contextDir);
|
: process.resourcesPath;
|
||||||
},
|
},
|
||||||
|
|
||||||
causesSideEffects: true,
|
causesSideEffects: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default lensResourcesDirInjectable;
|
export default lensResourcesDirInjectable;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user