1
0
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:
Janne Savolainen 2022-04-27 15:55:09 +03:00
parent 81ddf1153c
commit a3f139a40d
No known key found for this signature in database
GPG Key ID: 8C6CFB2FFFE8F68A
4 changed files with 38 additions and 11 deletions

View File

@ -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
*/ */

View File

@ -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,
}); });

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 isProductionInjectable = getInjectable({
id: "is-production",
instantiate: (di) => {
const { NODE_ENV: nodeEnv } = di.inject(environmentVariablesInjectable);
return nodeEnv === "production";
},
});
export default isProductionInjectable;

View File

@ -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;