From 22c3f3749b821357278975e5c95399433669b173 Mon Sep 17 00:00:00 2001 From: Sabir Hassan Date: Sun, 9 Oct 2022 14:10:14 +0500 Subject: [PATCH] fix: if a file is empty, ignore hash --- src/file/file.ts | 10 +++++++--- src/file/spec/hashFolder/emptyFile.txt | 0 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 src/file/spec/hashFolder/emptyFile.txt diff --git a/src/file/file.ts b/src/file/file.ts index a181c30..9229885 100644 --- a/src/file/file.ts +++ b/src/file/file.ts @@ -268,9 +268,13 @@ export const hashFileFolder = async ( ) => { if (!(await isFolder(resourcePath))) { const fileContent = fs.readFileSync(resourcePath) - const hash = createHash('md5') - hash.update(fileContent) - const generatedHash = hash.digest('hex').toUpperCase() + let generatedHash = '' + + if (fileContent.length) { + const hash = createHash('md5') + hash.update(fileContent) + generatedHash = hash.digest('hex').toUpperCase() + } return [ ...hashedResources, diff --git a/src/file/spec/hashFolder/emptyFile.txt b/src/file/spec/hashFolder/emptyFile.txt new file mode 100644 index 0000000..e69de29