mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Don't download binaries for unsupported windows
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
2d4d8e35c9
commit
f00e36b185
3 files changed
+16
-32
No files matched your search
@@ -9,14 +9,14 @@
|
||||
* It then only calls the function on the first call to `get()` and returns the
|
||||
* same instance/value on every subsequent call.
|
||||
*/
|
||||
export interface OnceCell<T> {
|
||||
export interface LazyInitialized<T> {
|
||||
get(): T;
|
||||
}
|
||||
|
||||
/**
|
||||
* A function to make a `OnceCell<T>`
|
||||
*/
|
||||
export function onceCell<T>(builder: () => T): OnceCell<T> {
|
||||
export function lazyInitialized<T>(builder: () => T): LazyInitialized<T> {
|
||||
let value: T | undefined;
|
||||
let called = false;
|
||||
|
||||
@@ -26,9 +26,10 @@ export function onceCell<T>(builder: () => T): OnceCell<T> {
|
||||
return value;
|
||||
}
|
||||
|
||||
value = builder();
|
||||
called = true;
|
||||
|
||||
return value = builder();
|
||||
return value;
|
||||
},
|
||||
};
|
||||
}
|
||||
+6
-6
@@ -8,7 +8,7 @@ import path from "path";
|
||||
import { SemVer } from "semver";
|
||||
import packageInfo from "../../package.json";
|
||||
import { defineGlobal } from "./utils/defineGlobal";
|
||||
import { onceCell } from "./utils/once-cell";
|
||||
import { lazyInitialized } from "./utils/once-cell";
|
||||
|
||||
export const isMac = process.platform === "darwin";
|
||||
export const isWindows = process.platform === "win32";
|
||||
@@ -66,18 +66,18 @@ export function getBinaryName(name: string, { forPlatform = normalizedPlatform }
|
||||
return name;
|
||||
}
|
||||
|
||||
export const resourcesDir = onceCell(() => (
|
||||
const resourcesDir = lazyInitialized(() => (
|
||||
isProduction
|
||||
? process.resourcesPath
|
||||
: path.join(process.cwd(), "binaries", "client", normalizedPlatform)
|
||||
));
|
||||
|
||||
export const baseBinariesDir = onceCell(() => path.join(resourcesDir.get(), normalizedArch));
|
||||
|
||||
export const baseBinariesDir = lazyInitialized(() => path.join(resourcesDir.get(), normalizedArch));
|
||||
export const kubeAuthProxyBinaryName = getBinaryName("lens-k8s-proxy");
|
||||
export const helmBinaryName = getBinaryName("helm");
|
||||
export const helmBinaryPath = onceCell(() => path.join(resourcesDir.get(), helmBinaryName));
|
||||
export const helmBinaryPath = lazyInitialized(() => path.join(baseBinariesDir.get(), helmBinaryName));
|
||||
export const kubectlBinaryName = getBinaryName("kubectl");
|
||||
export const kubectlBinaryPath = onceCell(() => path.join(baseBinariesDir.get(), kubectlBinaryName));
|
||||
export const kubectlBinaryPath = lazyInitialized(() => path.join(baseBinariesDir.get(), kubectlBinaryName));
|
||||
|
||||
// Webpack build paths
|
||||
export const contextDir = process.cwd();
|
||||
|
||||
Reference in new issue
Block a user