Last active
March 5, 2017 05:35
-
-
Save frankmarineau/0198c2b4768a306df33bedc929e3713d to your computer and use it in GitHub Desktop.
Filter PR files based on their name and the presence of additions.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const originalFiles = Array.from(document.querySelectorAll('.js-file')) | |
const container = document.querySelector('#files') | |
const isFileValid = el => { | |
// Exclude a certain file name pattern | |
const EXCLUSION_REGEX = /\.s?css$|^\ios\/|^\java\/|yarn\.lock|styles\.js|\.svg$/ | |
const fileName = el.querySelector('.file-header').dataset.path | |
if (fileName.match(EXCLUSION_REGEX)) return false | |
// Exclude files with no addition | |
if (!el.querySelector('.block-diff-added')) return false | |
return true | |
} | |
const filteredFiles = originalFiles.filter(fileEl => isFileValid(fileEl)) | |
container.innerHTML = '' | |
filteredFiles.forEach(f => container.append(f)) | |
console.log(`Filtered from ${originalFiles.length} to ${document.querySelectorAll('.js-file').length} files`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment