@@ -516,7 +516,7 @@ export function bufferFromFileOrString(file?: string, data?: string): Buffer | n
516516 return null ;
517517}
518518
519- function dropDuplicatesAndNils ( a : Array < string | null | undefined > ) : string [ ] {
519+ function dropDuplicatesAndNils ( a : string [ ] ) : 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.
@@ -543,11 +543,11 @@ export function findHomeDir(): string | null {
543543 // $HOME is always favored, but the k8s go-client prefers the other two env vars
544544 // differently depending on whether .kube/config exists or not.
545545 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 ] ) ;
551551 // 1. the first of %HOME%, %HOMEDRIVE%%HOMEPATH%, %USERPROFILE% containing a `.kube\config` file is returned.
552552 for ( const dir of favourHomeDrivePathList ) {
553553 try {
0 commit comments