1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Make splash screen not blow up by providing compile-time environment variables

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-28 10:50:00 +03:00
parent 0d41eabb64
commit 497c5258e6
No known key found for this signature in database
GPG Key ID: 8C6CFB2FFFE8F68A
2 changed files with 26 additions and 2 deletions

View File

@ -6,7 +6,25 @@ import { getInjectable } from "@ogre-tools/injectable";
const environmentVariablesInjectable = getInjectable({ const environmentVariablesInjectable = getInjectable({
id: "environment-variables", id: "environment-variables",
instantiate: () => process.env,
instantiate: () => {
// 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 = process.env.NODE_ENV;
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,
// Runtime environment variables
LENS_DISABLE_GPU: process.env.LENS_DISABLE_GPU,
};
},
causesSideEffects: true, causesSideEffects: true,
}); });

View File

@ -3,10 +3,16 @@
* 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 environmentVariablesInjectable from "../../../common/utils/environment-variables.injectable";
const directoryForIntegrationTestingInjectable = getInjectable({ const directoryForIntegrationTestingInjectable = getInjectable({
id: "directory-for-integration-testing", id: "directory-for-integration-testing",
instantiate: () => process.env.CICD,
instantiate: (di) => {
const environmentVariables = di.inject(environmentVariablesInjectable);
return environmentVariables.CICD;
},
}); });
export default directoryForIntegrationTestingInjectable; export default directoryForIntegrationTestingInjectable;