use fstatSync instead of statSync

This commit is contained in:
ddorando 2023-09-04 16:07:39 +03:00
parent 46db4850df
commit dad3602d2b
2 changed files with 9 additions and 4 deletions

8
dist/index.js vendored
View file

@ -654,9 +654,7 @@ class GitAuthHelper {
if (this.gitConfigPath.length === 0) {
this.gitConfigPath = yield this.git.getGitPath('config');
}
console.log(this.gitConfigPath);
let content = (yield fs.promises.readFile(this.gitConfigPath)).toString();
console.log(content);
const index = content.indexOf(find);
if (index < 0 || index != content.lastIndexOf(find)) {
throw new Error(`Unable to replace '${find}' in ${this.gitConfigPath}`);
@ -1413,9 +1411,10 @@ function fileExistsSync(path) {
if (!path) {
throw new Error("Arg 'path' must not be empty");
}
const fd = fs.openSync(path, 'r');
let stats;
try {
stats = fs.statSync(path);
stats = fs.fstatSync(fd);
}
catch (error) {
if (hasErrorCode(error) && error.code === 'ENOENT') {
@ -1423,6 +1422,9 @@ function fileExistsSync(path) {
}
throw new Error(`Encountered an error when checking whether path '${path}' exists: ${getErrorMessage(error)}`);
}
finally {
fs.closeSync(fd);
}
if (!stats.isDirectory()) {
return true;
}