From 01548bd51a95a8f5fb40f0e15a54f499ce2840f5 Mon Sep 17 00:00:00 2001 From: Lindsay Levine Date: Mon, 18 Jan 2021 09:00:59 -0500 Subject: [PATCH] check existence of dirs before reading them in file tracking logic --- lib/helpers/handleFileTracking.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/helpers/handleFileTracking.js b/lib/helpers/handleFileTracking.js index 5f19283..989c80c 100644 --- a/lib/helpers/handleFileTracking.js +++ b/lib/helpers/handleFileTracking.js @@ -56,12 +56,14 @@ const handleFileTracking = ({ functionsPath, publishPath }) => { // this callback will run at the end of nextOnNetlify() const trackNewFiles = () => { - const functionsAfterRun = isConfiguredFunctionsDir - ? readdirSync(functionsPath) - : functionsBeforeRun; - const publishAfterRun = isConfiguredPublishDir - ? readdirSync(publishPath) - : publishBeforeRun; + const functionsAfterRun = + isConfiguredFunctionsDir && existsSync(functionsPath) + ? readdirSync(functionsPath) + : functionsBeforeRun; + const publishAfterRun = + isConfiguredPublishDir && existsSync(publishPath) + ? readdirSync(publishPath) + : publishBeforeRun; const getDifference = (before, after) => after.filter((filePath) => !before.includes(filePath)); const newFunctionsFiles = getDifference(