Skip to content

Commit 78f64e1

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

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/config.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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)