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

Introduce injectable for __static directory to eliminate side effect on import

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-13 10:24:27 +03:00
parent cf052b9070
commit 5faaa7fa30
No known key found for this signature in database
GPG Key ID: 8C6CFB2FFFE8F68A
2 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,24 @@
/**
* 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 contextDirInjectable from "./context-dir.injectable";
import isDevelopmentInjectable from "./is-development.injectable";
const lensResourcesDirInjectable = getInjectable({
id: "lens-resources-dir",
instantiate: (di) => {
const isDevelopment = di.inject(isDevelopmentInjectable);
const contextDir = di.inject(contextDirInjectable);
return isDevelopment
? contextDir
: (process.resourcesPath ?? contextDir);
},
causesSideEffects: true,
});
export default lensResourcesDirInjectable;

View File

@ -0,0 +1,20 @@
/**
* 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 getAbsolutePathInjectable from "../path/get-absolute-path.injectable";
import lensResourcesDirInjectable from "./lens-resources-dir.injectable";
const staticDirInjectable = getInjectable({
id: "static-dir",
instantiate: (di) => {
const getAbsolutePath = di.inject(getAbsolutePathInjectable);
const lensResourcesDir = di.inject(lensResourcesDirInjectable);
return getAbsolutePath(lensResourcesDir, "static");
},
});
export default staticDirInjectable;