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

switch to using npm's which package

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2021-09-13 11:14:27 -04:00
parent f1fb1e2537
commit bac2d6e2ac
3 changed files with 9 additions and 7 deletions

View File

@ -185,6 +185,7 @@
"@kubernetes/client-node": "^0.15.1",
"@sentry/electron": "^2.5.0",
"@sentry/integrations": "^6.10.0",
"@types/which": "^2.0.1",
"abort-controller": "^3.0.0",
"array-move": "^3.0.1",
"auto-bind": "^4.0.0",
@ -245,6 +246,7 @@
"tempy": "^0.5.0",
"url-parse": "^1.5.1",
"uuid": "^8.3.2",
"which": "^2.0.2",
"win-ca": "^3.2.0",
"winston": "^3.3.3",
"winston-console-format": "^1.0.8",

View File

@ -29,7 +29,7 @@ import { ExecValidationNotFoundError } from "./custom-errors";
import { Cluster, Context, newClusters, newContexts, newUsers, User } from "@kubernetes/client-node/dist/config_types";
import { resolvePath } from "./utils";
import Joi from "joi";
import { execFileSync } from "child_process";
import which from "which";
export type KubeConfigValidationOpts = {
validateCluster?: boolean;
@ -296,17 +296,12 @@ export function validateKubeConfig(config: KubeConfig, contextName: string, vali
// Validate exec command if present
if (validateExec && user?.exec) {
try {
execFileSync(user.exec.command, { timeout: 1 });
which.sync(user.exec.command);
// If this doesn't throw an error it also means that it has found the executable.
} catch (error) {
switch (error?.code) {
case "ETIMEDOUT":
// ignore this error code. It means that the exec can be found.
break;
case "ENOENT":
case "EACCES":
case "EPERM":
return new ExecValidationNotFoundError(user.exec.command);
default:
return error;

View File

@ -2152,6 +2152,11 @@
anymatch "^3.0.0"
source-map "^0.6.0"
"@types/which@^2.0.1":
version "2.0.1"
resolved "https://registry.yarnpkg.com/@types/which/-/which-2.0.1.tgz#27ecd67f915b7c3d6ba552135bb1eecd66e63501"
integrity sha512-Jjakcv8Roqtio6w1gr0D7y6twbhx6gGgFGF5BLwajPpnOIOxFkakFhCq+LmyyeAz7BX6ULrjBOxdKaCDy+4+dQ==
"@types/ws@^6.0.1":
version "6.0.4"
resolved "https://registry.yarnpkg.com/@types/ws/-/ws-6.0.4.tgz#7797707c8acce8f76d8c34b370d4645b70421ff1"