Skip to content

Commit 0946223

Browse files
Be sure to exit from resolved promise deleteIfExists(...) helper
Failing to exit when the specified file path doens't exist means that we try to delete that file even though it doesn't exist. This results in a timing issue because the deletion is asynchronous. Essentially, it might unintentionally delete the file springs into being before the promise is resolved.
1 parent e7c4caa commit 0946223

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export function deleteIfExists(filePath: string): Promise<void> {
7878
.then((exists: boolean) => {
7979
return new Promise<void>((resolve, reject) => {
8080
if (!exists) {
81-
resolve();
81+
return resolve();
8282
}
8383

8484
fs.unlink(filePath, err => {

0 commit comments

Comments
 (0)