mirror of
https://forgejo.stefka.eu/jiriks74/create-pull-request.git
synced 2025-01-18 16:01:06 +01:00
use fstatSync instead of statSync
This commit is contained in:
parent
46db4850df
commit
dad3602d2b
2 changed files with 9 additions and 4 deletions
8
dist/index.js
vendored
8
dist/index.js
vendored
|
@ -654,9 +654,7 @@ class GitAuthHelper {
|
||||||
if (this.gitConfigPath.length === 0) {
|
if (this.gitConfigPath.length === 0) {
|
||||||
this.gitConfigPath = yield this.git.getGitPath('config');
|
this.gitConfigPath = yield this.git.getGitPath('config');
|
||||||
}
|
}
|
||||||
console.log(this.gitConfigPath);
|
|
||||||
let content = (yield fs.promises.readFile(this.gitConfigPath)).toString();
|
let content = (yield fs.promises.readFile(this.gitConfigPath)).toString();
|
||||||
console.log(content);
|
|
||||||
const index = content.indexOf(find);
|
const index = content.indexOf(find);
|
||||||
if (index < 0 || index != content.lastIndexOf(find)) {
|
if (index < 0 || index != content.lastIndexOf(find)) {
|
||||||
throw new Error(`Unable to replace '${find}' in ${this.gitConfigPath}`);
|
throw new Error(`Unable to replace '${find}' in ${this.gitConfigPath}`);
|
||||||
|
@ -1413,9 +1411,10 @@ function fileExistsSync(path) {
|
||||||
if (!path) {
|
if (!path) {
|
||||||
throw new Error("Arg 'path' must not be empty");
|
throw new Error("Arg 'path' must not be empty");
|
||||||
}
|
}
|
||||||
|
const fd = fs.openSync(path, 'r');
|
||||||
let stats;
|
let stats;
|
||||||
try {
|
try {
|
||||||
stats = fs.statSync(path);
|
stats = fs.fstatSync(fd);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
if (hasErrorCode(error) && error.code === 'ENOENT') {
|
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)}`);
|
throw new Error(`Encountered an error when checking whether path '${path}' exists: ${getErrorMessage(error)}`);
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
|
fs.closeSync(fd);
|
||||||
|
}
|
||||||
if (!stats.isDirectory()) {
|
if (!stats.isDirectory()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,9 +147,10 @@ export function fileExistsSync(path: string): boolean {
|
||||||
throw new Error("Arg 'path' must not be empty")
|
throw new Error("Arg 'path' must not be empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const fd = fs.openSync(path, 'r')
|
||||||
let stats: fs.Stats
|
let stats: fs.Stats
|
||||||
try {
|
try {
|
||||||
stats = fs.statSync(path)
|
stats = fs.fstatSync(fd)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (hasErrorCode(error) && error.code === 'ENOENT') {
|
if (hasErrorCode(error) && error.code === 'ENOENT') {
|
||||||
return false
|
return false
|
||||||
|
@ -160,6 +161,8 @@ export function fileExistsSync(path: string): boolean {
|
||||||
error
|
error
|
||||||
)}`
|
)}`
|
||||||
)
|
)
|
||||||
|
} finally {
|
||||||
|
fs.closeSync(fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stats.isDirectory()) {
|
if (!stats.isDirectory()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue