@@ -516,7 +516,7 @@ export function bufferFromFileOrString(file?: string, data?: string): Buffer | n
516
516
return null ;
517
517
}
518
518
519
- function dropDuplicatesAndNils ( a ) : string [ ] {
519
+ function dropDuplicatesAndNils ( a : Array < string | null | undefined > ) : string [ ] {
520
520
return a . reduce ( ( acceptedValues , currentValue ) => {
521
521
// Good-enough algorithm for reducing a small (3 items at this point) array into an ordered list
522
522
// of unique non-empty strings.
@@ -540,7 +540,8 @@ export function findHomeDir(): string | null {
540
540
}
541
541
return null ;
542
542
}
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 ;
544
545
const dirList1 : string [ ] = dropDuplicatesAndNils ( [ process . env . HOME , homeDrivePath , process . env . USERPROFILE ] ) ;
545
546
const dirList2 : string [ ] = dropDuplicatesAndNils ( [ process . env . HOME , process . env . USERPROFILE , homeDrivePath ] ) ;
546
547
// 1. the first of %HOME%, %HOMEDRIVE%%HOMEPATH%, %USERPROFILE% containing a `.kube\config` file is returned.
@@ -555,7 +556,7 @@ export function findHomeDir(): string | null {
555
556
for ( const dir of dirList2 ) {
556
557
try {
557
558
const lstat = fs . lstatSync ( dir ) ;
558
- // tslint:disable-next-line:no-bitwise
559
+ // tslint:disable-next-line:no-bitwise
559
560
if ( lstat && ( lstat . mode & fs . constants . S_IXUSR ) === fs . constants . S_IXUSR ) {
560
561
return dir ;
561
562
}
@@ -570,8 +571,9 @@ export function findHomeDir(): string | null {
570
571
// tslint:disable-next-line:no-empty
571
572
} catch ( ignore ) { }
572
573
}
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 ;
575
577
}
576
578
577
579
export interface Named {
0 commit comments