Skip to content

Commit 514bea3

Browse files
committed
Lint-driven fixes
1 parent a0202e3 commit 514bea3

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/config.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ export function bufferFromFileOrString(file?: string, data?: string): Buffer | n
516516
return null;
517517
}
518518

519-
function dropDuplicatesAndNils(a): string[] {
519+
function dropDuplicatesAndNils(a: Array<string | null | undefined>): string[] {
520520
return a.reduce((acceptedValues, currentValue) => {
521521
// Good-enough algorithm for reducing a small (3 items at this point) array into an ordered list
522522
// of unique non-empty strings.
@@ -540,7 +540,8 @@ export function findHomeDir(): string | null {
540540
}
541541
return null;
542542
}
543-
const homeDrivePath = process.env.HOMEDRIVE && process.env.HOMEPATH ? path.join(process.env.HOMEDRIVE, process.env.HOMEPATH) : null;
543+
const homeDrivePath = process.env.HOMEDRIVE && process.env.HOMEPATH ?
544+
path.join(process.env.HOMEDRIVE, process.env.HOMEPATH) : null;
544545
const dirList1: string[] = dropDuplicatesAndNils([process.env.HOME, homeDrivePath, process.env.USERPROFILE]);
545546
const dirList2: string[] = dropDuplicatesAndNils([process.env.HOME, process.env.USERPROFILE, homeDrivePath]);
546547
// 1. the first of %HOME%, %HOMEDRIVE%%HOMEPATH%, %USERPROFILE% containing a `.kube\config` file is returned.
@@ -555,7 +556,7 @@ export function findHomeDir(): string | null {
555556
for (const dir of dirList2) {
556557
try {
557558
const lstat = fs.lstatSync(dir);
558-
// tslint:disable-next-line:no-bitwise
559+
// tslint:disable-next-line:no-bitwise
559560
if (lstat && (lstat.mode & fs.constants.S_IXUSR) === fs.constants.S_IXUSR) {
560561
return dir;
561562
}
@@ -570,8 +571,9 @@ export function findHomeDir(): string | null {
570571
// tslint:disable-next-line:no-empty
571572
} catch (ignore) {}
572573
}
573-
// 4. if none of those locations exists, the first of %HOME%, %USERPROFILE%, %HOMEDRIVE%%HOMEPATH% that is set is returned.
574-
return dirList2[0] ?? null;
574+
// 4. if none of those locations exists, the first of
575+
// %HOME%, %USERPROFILE%, %HOMEDRIVE%%HOMEPATH% that is set is returned.
576+
return dirList2[0] || null;
575577
}
576578

577579
export interface Named {

0 commit comments

Comments
 (0)