Skip to content

Commit

Permalink
Exclude .git directory content for package file count
Browse files Browse the repository at this point in the history
  • Loading branch information
qtomlinson committed Oct 31, 2023
1 parent a793608 commit 6eead81
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion providers/process/abstractClearlyDefinedProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class AbstractClearlyDefinedProcessor extends AbstractProcessor {
let count = 0
const bytes = await du(location, {
filter: file => {
if (path.basename(file) === '.git') return false
if (!this.isValidExcludingGit(file)) return false
count++
return true
}
Expand Down
18 changes: 12 additions & 6 deletions providers/process/abstractProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,21 @@ class AbstractProcessor extends BaseHandler {
*/
async filterFiles(location) {
const fullList = await this.getFiles(location)
const exclusions = ['.git']
const filteredList = fullList.filter(file => {
if (!file) return false
const segments = file.split(/[\\/]/g)
return !intersection(segments, exclusions).length
})
const filteredList = fullList.filter(file => this.isValidExcludingGit(file))
return trimAllParents(filteredList, location).filter(x => x)
}

_isValid(file, exclusions) {
if (!file) return false
const segments = file.split(/[\\/]/g)
return !intersection(segments, exclusions).length
}

isValidExcludingGit(file) {
const exclusions = ['.git']
return this._isValid(file, exclusions)
}

shouldFetch() {
return true
}
Expand Down

0 comments on commit 6eead81

Please sign in to comment.