Skip to content

Commit ad25e51

Browse files
committed
Prefer fs.access(..., 'w') to fs.lstat() & BITS
1 parent e8be08b commit ad25e51

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/config.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ export function findHomeDir(): string | null {
543543
}
544544
return null;
545545
}
546-
// $HOME is always favored, but the k8s go-client prefers the other two env vars
546+
// $HOME is always favoured, but the k8s go-client prefers the other two env vars
547547
// differently depending on whether .kube/config exists or not.
548548
const homeDrivePath =
549549
process.env.HOMEDRIVE && process.env.HOMEPATH
@@ -564,11 +564,8 @@ export function findHomeDir(): string | null {
564564
// 2. ...the first of %HOME%, %USERPROFILE%, %HOMEDRIVE%%HOMEPATH% that exists and is writeable is returned
565565
for (const dir of favourUserProfileList) {
566566
try {
567-
const lstat = fs.lstatSync(dir);
568-
// tslint:disable-next-line:no-bitwise
569-
if (lstat && (lstat.mode & fs.constants.S_IXUSR) === fs.constants.S_IXUSR) {
570-
return dir;
571-
}
567+
fs.accessSync(dir, fs.constants.W_OK);
568+
return dir;
572569
// tslint:disable-next-line:no-empty
573570
} catch (ignore) {}
574571
}

0 commit comments

Comments
 (0)