mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
refactor isDevelopment & contextDir to injectables
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
c8ac776d25
commit
93a6a58ea4
@ -4,13 +4,14 @@
|
|||||||
*/
|
*/
|
||||||
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
|
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import { isDevelopment, contextDir } from "../../vars";
|
import isDevelopmentInjectable from "../../vars/is-development.injectable";
|
||||||
|
import contextDirInjectable from "../../vars/context-dir.injectable";
|
||||||
import directoryForUserDataInjectable from "../directory-for-user-data/directory-for-user-data.injectable";
|
import directoryForUserDataInjectable from "../directory-for-user-data/directory-for-user-data.injectable";
|
||||||
|
|
||||||
const directoryForBinariesInjectable = getInjectable({
|
const directoryForBinariesInjectable = getInjectable({
|
||||||
instantiate: (di) => {
|
instantiate: (di) => {
|
||||||
if (isDevelopment) {
|
if (di.inject(isDevelopmentInjectable)) {
|
||||||
return path.join(contextDir, "binaries");
|
return path.join(di.inject(contextDirInjectable), "binaries");
|
||||||
}
|
}
|
||||||
|
|
||||||
return path.join(di.inject(directoryForUserDataInjectable), "binaries");
|
return path.join(di.inject(directoryForUserDataInjectable), "binaries");
|
||||||
|
|||||||
13
src/common/vars/context-dir.injectable.ts
Normal file
13
src/common/vars/context-dir.injectable.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
|
||||||
|
import { contextDir } from "../vars";
|
||||||
|
|
||||||
|
const contextDirInjectable = getInjectable({
|
||||||
|
instantiate: () => contextDir,
|
||||||
|
lifecycle: lifecycleEnum.singleton,
|
||||||
|
});
|
||||||
|
|
||||||
|
export default contextDirInjectable;
|
||||||
13
src/common/vars/is-development.injectable.ts
Normal file
13
src/common/vars/is-development.injectable.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
|
||||||
|
import { isDevelopment } from "../vars";
|
||||||
|
|
||||||
|
const isDevelopmentInjectable = getInjectable({
|
||||||
|
instantiate: () => isDevelopment,
|
||||||
|
lifecycle: lifecycleEnum.singleton,
|
||||||
|
});
|
||||||
|
|
||||||
|
export default isDevelopmentInjectable;
|
||||||
Loading…
Reference in New Issue
Block a user