Skip to content

Commit 4d438ef

Browse files
committed
chore: use async fs calls
1 parent b75cc53 commit 4d438ef

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/adapters/apply-edit-adapter.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export default class ApplyEditAdapter {
9393
private static async handleResourceOperation(edit: (CreateFile | RenameFile | DeleteFile)): Promise<void> {
9494
if (DeleteFile.is(edit)) {
9595
const path = Convert.uriToPath(edit.uri)
96-
const exists = fs.existsSync(path)
96+
const exists = await fs.promises.stat(path).then(() => true).catch(() => false)
9797
const ignoreIfNotExists = edit.options?.ignoreIfNotExists
9898

9999
if (!exists) {
@@ -124,7 +124,7 @@ export default class ApplyEditAdapter {
124124
if (RenameFile.is(edit)) {
125125
const oldPath = Convert.uriToPath(edit.oldUri)
126126
const newPath = Convert.uriToPath(edit.newUri)
127-
const exists = fs.existsSync(newPath)
127+
const exists = await fs.promises.stat(newPath).then(() => true).catch(() => false)
128128
const ignoreIfExists = edit.options?.ignoreIfExists
129129
const overwrite = edit.options?.overwrite
130130

@@ -140,7 +140,7 @@ export default class ApplyEditAdapter {
140140
}
141141
if (CreateFile.is(edit)) {
142142
const path = Convert.uriToPath(edit.uri)
143-
const exists = fs.existsSync(path)
143+
const exists = await fs.promises.stat(path).then(() => true).catch(() => false)
144144
const ignoreIfExists = edit.options?.ignoreIfExists
145145
const overwrite = edit.options?.overwrite
146146

0 commit comments

Comments
 (0)