From b90767926fd28593b7fd61a7ea349ee477d378cb Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 23 Feb 2021 22:53:24 +0100 Subject: [PATCH] scaffolder-backend: remove workspace after task execution is complete Signed-off-by: Johan Haals --- .../scaffolder-backend/src/scaffolder/tasks/TaskWorker.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/scaffolder-backend/src/scaffolder/tasks/TaskWorker.ts b/plugins/scaffolder-backend/src/scaffolder/tasks/TaskWorker.ts index 032fea6410..4a09149bab 100644 --- a/plugins/scaffolder-backend/src/scaffolder/tasks/TaskWorker.ts +++ b/plugins/scaffolder-backend/src/scaffolder/tasks/TaskWorker.ts @@ -44,10 +44,11 @@ export class TaskWorker { } async runOneTask(task: Task) { + let workspacePath: string | undefined = undefined; try { const { actionRegistry } = this.options; - const workspacePath = path.join( + workspacePath = path.join( this.options.workingDirectory, await task.getWorkspaceName(), ); @@ -172,6 +173,10 @@ export class TaskWorker { await task.complete('failed', { error: { name: error.name, message: error.message }, }); + } finally { + if (workspacePath) { + await fs.remove(workspacePath); + } } } }