Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
document.querySelectorAll('.Box-row .js-navigation-open').forEach( (item) => {
const filename = item.textContent.toLowerCase();
const humanFiles = ['AUTHORS', 'CHANGELOG', 'CODE_OF_CONDUCT', 'CONTRIBUTING', 'LICENSE', 'README', 'TECHNOLOGY', 'TROUBLESHOOTING', 'SECURITY'];
const row = item.parentNode.parentNode.parentNode;
if((filename != 'src' && filename.endsWith('rc'))
|| filename.includes('config')
|| filename.includes('ignore')
|| filename.includes('.conf.js')
|| filename.includes('webpack')
|| filename == 'robots.txt'
|| filename == 'sitemap.xml'
|| filename == 'cname'
|| filename.endsWith('.toml')
|| filename.endsWith('.json')
|| filename.endsWith('.json5')
|| filename.endsWith('.yml')
|| filename.endsWith('.yaml')
|| filename.endsWith('.lock')
|| filename.endsWith('-lock.json')
|| filename.endsWith('.bazel')
|| filename.startsWith('gemfile')
|| filename.startsWith('gruntfile')
|| filename.startsWith('gulpfile')
|| filename.startsWith('.')
){
row.style.background = '#fee9e8'
} else if(humanFiles.includes(item.textContent.split('-')[0].split('.')[0])) {
row.style.background = '#edf6fd'
}
})
@jimniels

This comment has been minimized.

Copy link

@jimniels jimniels commented Feb 2, 2021

A couple quick suggestions based on a few repos I looked at:

item.textContent.endsWith('.json5')
I did not know this, but apparently json5 is a thing and is in the Gatsy repo for a dependency management tool.

item.textContent.endsWith('.yml')
item.textContent.endsWith('.yaml')
Because, you know, more ways to config.

item.textContent.endsWith('.lock')
item.textContent.endsWith('-lock.json')
Those would both catch yarn.lock and package-lock.json

item.textContent.endsWith('.bazel')
Never used it, but seen it on projects.

item.textContent.includes('.conf.js')
Another pattern I've seen.

item.textContent.includes('webpack')
Because I've seen webpack have "base configs" which get named like webpackBaseConfig.js

Other
Maybe set item.textContent to a var name and do .toLowerCase() because it'll catch gulpfile.js but not Gulpfile.js.

@davatron5000

This comment has been minimized.

Copy link
Owner Author

@davatron5000 davatron5000 commented Feb 2, 2021

@jimniels Major upgrades! Lot more readable now.

@CITguy

This comment has been minimized.

Copy link

@CITguy CITguy commented Feb 3, 2021

So is this gist for humans or robots? 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment