From 094622317fc5c5c3b37bdeff2627bab16b45d878 Mon Sep 17 00:00:00 2001 From: Dustin Campbell Date: Fri, 21 Apr 2017 11:25:38 -0700 Subject: [PATCH] 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. --- src/common.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.ts b/src/common.ts index ede27ead6..58b1ced8b 100644 --- a/src/common.ts +++ b/src/common.ts @@ -78,7 +78,7 @@ export function deleteIfExists(filePath: string): Promise { .then((exists: boolean) => { return new Promise((resolve, reject) => { if (!exists) { - resolve(); + return resolve(); } fs.unlink(filePath, err => {