diff options
Diffstat (limited to 'functions/misc_functions.sh')
-rw-r--r-- | functions/misc_functions.sh | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/functions/misc_functions.sh b/functions/misc_functions.sh index 728c6e453b8a..5e36733f791b 100644 --- a/functions/misc_functions.sh +++ b/functions/misc_functions.sh @@ -46,6 +46,23 @@ function trim { } +# Extends `codemod` to exclude dirs in .gitignore file +function cm { + extensions="$1" + regex="$2" + replacement="$3" + + ignore_dirs="" + + if [ -f ./.gitignore ]; then + # Sanitizes .gitignore and converts it to a comma-separated list + ignore_dirs="$(sed 's/^\//.\//g' <./.gitignore | sed -e 's/#.*$//' -e '/^$/d' | tr '\n' ',' | sed 's/,$//')" + fi + + codemod -m -d . --extensions ${extensions} --exclude-paths ${ignore_dirs} ${regex} ${replacement} +} + + function tt() { sessionName="${1}" if ! tmux has-session -t "${sessionName}" 2> /dev/null; then |