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

resolve review comments

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2020-11-23 13:38:29 -05:00
parent b3a01fac2f
commit 7fadcda642
2 changed files with 8 additions and 5 deletions

View File

@ -21,7 +21,9 @@ module.exports = {
sourceType: 'module', sourceType: 'module',
}, },
rules: { rules: {
"indent": ["error", 2], "indent": ["error", 2, {
"SwitchCase": 1,
}],
"no-unused-vars": "off", "no-unused-vars": "off",
"semi": ["error", "always"], "semi": ["error", "always"],
"object-shorthand": "error", "object-shorthand": "error",

View File

@ -28,7 +28,7 @@ export class AccessError extends LoadKubeError {
} }
toString() { toString() {
return `Failed to loading the kube config. Permission denied.\n\n${this.pathname}`; return `Failed loading the kube config. Permission denied.\n\n${this.pathname}`;
} }
} }
@ -40,18 +40,19 @@ export class ExistError extends LoadKubeError {
} }
toString() { toString() {
return `Failed to loading the kube config. No such file.\n\n${this.pathname}`; return `Failed loading the kube config. No such file.\n\n${this.pathname}`;
} }
} }
export function loadConfig(pathOrContent: string): KubeConfig { export function loadConfig(pathOrContent: string): KubeConfig {
const kc = new KubeConfig(); const kc = new KubeConfig();
const pathVersion = resolveTilde(pathOrContent);
try { try {
kc.loadFromFile(pathOrContent); kc.loadFromFile(pathVersion);
} catch (err) { } catch (err) {
switch (err.code) { switch (err.code) {
case "ENOENT": { // No such file or directory case "ENOENT": { // No such file or directory
const dir = path.dirname(pathOrContent); const dir = path.dirname(pathVersion);
const dirStat = fse.statSync(dir); const dirStat = fse.statSync(dir);
if (dirStat.isDirectory()) { if (dirStat.isDirectory()) {
throw new ExistError(pathOrContent); throw new ExistError(pathOrContent);