Last active
April 18, 2020 03:59
-
-
Save troy0820/c1dbd27f30e0c38f015b15113eb7a2b9 to your computer and use it in GitHub Desktop.
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 | |
set -e | |
files=$(find . -name ".editorconfig" ! -path './vendor/*') | |
gitfiles=$(git diff --cached --name-only) | |
if [[ "${files}" == "./.editorconfig" ]]; then | |
echo -e "\033[032m.editorconfig file exists \033[0m" | |
for f in $gitfiles | |
do | |
git add $f | |
done | |
else | |
echo -e "\033[032mNo editorconfig; Adding one now \033[0m" | |
touch .editorconfig | |
cat <<EOF > .editorconfig | |
# EditorConfig helps developers define and maintain consistent | |
# coding styles between different editors and IDEs | |
# editorconfig.org | |
root = true | |
[*] | |
# Change these settings to your own preference | |
indent_style = space | |
indent_size = 2 | |
# We recommend you to keep these unchanged | |
end_of_line = lf | |
charset = utf-8 | |
trim_trailing_whitespace = true | |
insert_final_newline = true | |
[{Makefile,**.mk}] | |
# Use tabs for indentation (Makefiles require tabs) | |
indent_style = tab | |
EOF | |
echo -e "\033[032Now you have one\033[0m" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment