From 15df9f3778f5d375879b3504fdf759560b43ba68 Mon Sep 17 00:00:00 2001 From: kubama Date: Thu, 30 Mar 2023 10:02:17 +0200 Subject: [PATCH] RND-102 Fix repo removal on exception (#161) --- packages/backend/src/git.ts | 2 +- packages/backend/test/git.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/git.ts b/packages/backend/src/git.ts index 1af83d3..83836df 100644 --- a/packages/backend/src/git.ts +++ b/packages/backend/src/git.ts @@ -51,5 +51,5 @@ export const cloneGitRepo = async ( }; const removeGitRepo = (repositoryPath: string) => { - fs.rmdirSync(repositoryPath, { recursive: true }); + if (fs.existsSync(repositoryPath)) fs.rmdirSync(repositoryPath, { recursive: true }); }; diff --git a/packages/backend/test/git.test.ts b/packages/backend/test/git.test.ts index 31b7b01..769159d 100644 --- a/packages/backend/test/git.test.ts +++ b/packages/backend/test/git.test.ts @@ -27,6 +27,6 @@ describe('git', () => { '--filter=blob:none' ]); expect(callback).toHaveBeenCalledWith(repositoryPath); - expect(fs.rmdirSync).toHaveBeenCalledWith(repositoryPath, { recursive: true }); + expect(fs.existsSync).toHaveBeenCalledWith(repositoryPath); }); });