Skip to content

Instantly share code, notes, and snippets.

@davatron5000
Last active February 3, 2021 19:38
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davatron5000/9db6a622a6f2203ec1f900512d6fae86 to your computer and use it in GitHub Desktop.
Save davatron5000/9db6a622a6f2203ec1f900512d6fae86 to your computer and use it in GitHub Desktop.
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
Copy link

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
Copy link
Author

@jimniels Major upgrades! Lot more readable now.

@CITguy
Copy link

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