Last active
April 14, 2019 19:44
-
-
Save nevstokes/282ca190de58a3ff032bcdfb8e692185 to your computer and use it in GitHub Desktop.
Generate individual ignore files from unified yaml
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
eslint: | |
- node_modules/ | |
- "*.d.ts" | |
docker: | |
- .env.dist | |
- node_modules | |
- README.md | |
git: | |
- .*ignore | |
- .env | |
- bin/*.js | |
- lib/*.js | |
- "*.d.ts" | |
- node_modules | |
npm: | |
- "*.ts" | |
- !*.d.ts |
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
#!/usr/bin/env bash | |
if [[ "$#" -ne 1 ]]; then | |
echo "Usage: $0 IGNOREFILE" >&2 | |
exit 1 | |
fi | |
IGNOREFILE=$1 | |
if ! [[ -f "${IGNOREFILE}" ]]; then | |
echo "${IGNOREFILE} not found" >&2 | |
exit 1 | |
fi | |
while read ignore; do | |
match=$(printf '/^%s:/,/^[^\s-]+:/p' ${ignore}) | |
output=$(printf '.%signore\n' ${ignore}) | |
sed -nE ${match} ${IGNOREFILE} | sed -nE 's/^\s*-\s*//p' > ${output} | |
done < <(sed -nE 's/^([a-z]+):/\1/p' ${IGNOREFILE}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Unified ignore
I'm fed up of having several ignore files littering my repositories. This script will generate many ignores from one keyed yaml file.
Usage
zsh plugin
A plugin for zsh is available to automatically create the individual ignore files upon entering a directory.