From 9090c3a91f32e1f34ddb189d0f29b282b93f45f4 Mon Sep 17 00:00:00 2001 From: davemooreuws Date: Wed, 27 Oct 2021 10:11:35 +1100 Subject: [PATCH] fix: check build directory exists before deletion --- packages/common/src/task/build-function.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/common/src/task/build-function.ts b/packages/common/src/task/build-function.ts index 7db2589a..74968812 100644 --- a/packages/common/src/task/build-function.ts +++ b/packages/common/src/task/build-function.ts @@ -110,7 +110,7 @@ export class BuildFunctionTask extends Task { await fs.promises.unlink(`./${contextBuildDirectory}/${imageId}.toml`); // remove build directory if empty - if (fs.readdirSync(contextBuildDirectory).length === 0) { + if (fs.existsSync(contextBuildDirectory) && fs.readdirSync(contextBuildDirectory).length === 0) { await fs.promises.rmdir(contextBuildDirectory); } } catch (e) {