@@ -517,15 +517,18 @@ export function bufferFromFileOrString(file?: string, data?: string): Buffer | n
517
517
}
518
518
519
519
function dropDuplicatesAndNils ( a : string [ ] ) : string [ ] {
520
- return a . reduce ( ( acceptedValues , currentValue ) => {
521
- // Good-enough algorithm for reducing a small (3 items at this point) array into an ordered list
522
- // of unique non-empty strings.
523
- if ( currentValue && ! acceptedValues . includes ( currentValue ) ) {
524
- return acceptedValues . concat ( currentValue ) ;
525
- } else {
526
- return acceptedValues ;
527
- }
528
- } , [ ] as string [ ] ) ;
520
+ return a . reduce (
521
+ ( acceptedValues , currentValue ) => {
522
+ // Good-enough algorithm for reducing a small (3 items at this point) array into an ordered list
523
+ // of unique non-empty strings.
524
+ if ( currentValue && ! acceptedValues . includes ( currentValue ) ) {
525
+ return acceptedValues . concat ( currentValue ) ;
526
+ } else {
527
+ return acceptedValues ;
528
+ }
529
+ } ,
530
+ [ ] as string [ ] ,
531
+ ) ;
529
532
}
530
533
531
534
// Only public for testing.
@@ -542,8 +545,10 @@ export function findHomeDir(): string | null {
542
545
}
543
546
// $HOME is always favored, but the k8s go-client prefers the other two env vars
544
547
// differently depending on whether .kube/config exists or not.
545
- const homeDrivePath = process . env . HOMEDRIVE && process . env . HOMEPATH ?
546
- path . join ( process . env . HOMEDRIVE , process . env . HOMEPATH ) : '' ;
548
+ const homeDrivePath =
549
+ process . env . HOMEDRIVE && process . env . HOMEPATH
550
+ ? path . join ( process . env . HOMEDRIVE , process . env . HOMEPATH )
551
+ : '' ;
547
552
const homePath = process . env . HOME || '' ;
548
553
const userProfile = process . env . USERPROFILE || '' ;
549
554
const favourHomeDrivePathList : string [ ] = dropDuplicatesAndNils ( [ homePath , homeDrivePath , userProfile ] ) ;
@@ -560,7 +565,7 @@ export function findHomeDir(): string | null {
560
565
for ( const dir of favourUserProfileList ) {
561
566
try {
562
567
const lstat = fs . lstatSync ( dir ) ;
563
- // tslint:disable-next-line:no-bitwise
568
+ // tslint:disable-next-line:no-bitwise
564
569
if ( lstat && ( lstat . mode & fs . constants . S_IXUSR ) === fs . constants . S_IXUSR ) {
565
570
return dir ;
566
571
}
0 commit comments