@@ -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 : Array < string | null | undefined > ) : string [ ] {
519
+ function dropDuplicatesAndNils ( a : string [ ] ) : 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.
@@ -543,11 +543,11 @@ export function findHomeDir(): string | null {
543
543
// $HOME is always favored, but the k8s go-client prefers the other two env vars
544
544
// differently depending on whether .kube/config exists or not.
545
545
const homeDrivePath = process . env . HOMEDRIVE && process . env . HOMEPATH ?
546
- path . join ( process . env . HOMEDRIVE , process . env . HOMEPATH ) : null ;
547
- const favourHomeDrivePathList : string [ ] =
548
- dropDuplicatesAndNils ( [ process . env . HOME , homeDrivePath , process . env . USERPROFILE ] ) ;
549
- const favourUserProfileList : string [ ] =
550
- dropDuplicatesAndNils ( [ process . env . HOME , process . env . USERPROFILE , homeDrivePath ] ) ;
546
+ path . join ( process . env . HOMEDRIVE , process . env . HOMEPATH ) : '' ;
547
+ const homePath = process . env . HOME || '' ;
548
+ const userProfile = process . env . USERPROFILE || '' ;
549
+ const favourHomeDrivePathList : string [ ] = dropDuplicatesAndNils ( [ homePath , homeDrivePath , userProfile ] ) ;
550
+ const favourUserProfileList : string [ ] = dropDuplicatesAndNils ( [ homePath , userProfile , homeDrivePath ] ) ;
551
551
// 1. the first of %HOME%, %HOMEDRIVE%%HOMEPATH%, %USERPROFILE% containing a `.kube\config` file is returned.
552
552
for ( const dir of favourHomeDrivePathList ) {
553
553
try {
0 commit comments