Skip to content

Commit

Permalink
[Misc] Test hash function update (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
anirudhprasad-sap authored Aug 20, 2024
1 parent 1269d38 commit ca3fae0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,6 @@ dist

# TernJS port file
.tern-port

# Test app folder
*.tmp/
9 changes: 4 additions & 5 deletions test/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ function getFolderHash(folder) {
const hashes = []

files.forEach(file => {
const data = fs.readFileSync(file)
const hash = crypto.createHash('md5').update(data).digest('hex')
hashes.push(hash)
hashes.push(getFileHash(file))
})

// Combine all hashes to generate a unique hash for the folder
Expand All @@ -18,8 +16,9 @@ function getFolderHash(folder) {
}

function getFileHash(file){
const data = fs.readFileSync(file)
const hash = crypto.createHash('md5').update(data).digest('hex')
const data = fs.readFileSync(file, 'utf8')
const normalizedData = data.replace(/\r\n/g, '\n') // Normalize line endings
const hash = crypto.createHash('md5').update(normalizedData).digest('hex')
return hash
}

Expand Down

0 comments on commit ca3fae0

Please sign in to comment.