From 3f119b7a0e444b1c16223c05f1965cc6a0534b42 Mon Sep 17 00:00:00 2001 From: "dave.shepard" Date: Tue, 11 Apr 2023 21:20:06 -0700 Subject: [PATCH] Add support for new files in a new folder --- src/gitBackup.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gitBackup.js b/src/gitBackup.js index 9876ab1..1a806a5 100644 --- a/src/gitBackup.js +++ b/src/gitBackup.js @@ -102,11 +102,13 @@ async function getStatuses() { if (match) { const status = STATUSES[match[1]]; const filePath = match[2]; - const filePathStatus = fs.statSync(path.resolve(APP_ROOT_FOLDER, filePath)); + const absPath = path.resolve(APP_ROOT_FOLDER, filePath); + const filePathStatus = fs.existsSync(absPath) ? fs.statSync(absPath) : false; + const isDirectory = filePathStatus ? filePathStatus.isDirectory() : false; // Folders in the status output indicate completely un-tracked folders - if (filePathStatus.isDirectory()) { - fs.readdirSync(filePath).forEach((node) => { + if (isDirectory) { + fs.readdirSync(absPath).forEach((node) => { statuses.push({ status: STATUS_NEW, filePath: path.join(filePath, node)