Tolerate BSD sed and don't try to sed inside the .pyc files (#25)
This commit is contained in:
parent
eebfcac9bb
commit
c7752db54c
1 changed files with 13 additions and 3 deletions
|
@ -7,6 +7,11 @@ then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# GNU sed and BSD(Mac) sed handle -i differently :(
|
||||||
|
function is_gnu_sed(){
|
||||||
|
sed --version >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
# Allow specifying either:
|
# Allow specifying either:
|
||||||
# * One argument, which is the new project name, assuming the old project name is "my project name"
|
# * One argument, which is the new project name, assuming the old project name is "my project name"
|
||||||
# * Or two arguments, where one can specify 1. the old project name and 2. the new project name
|
# * Or two arguments, where one can specify 1. the old project name and 2. the new project name
|
||||||
|
@ -42,11 +47,16 @@ find . -type d -not -path "./env*" -not -path "./.git" -not -path "./.git*" \
|
||||||
echo "Updating references within files..."
|
echo "Updating references within files..."
|
||||||
|
|
||||||
# Iterate through each file and replace strings within files
|
# Iterate through each file and replace strings within files
|
||||||
for file in $(grep --exclude-dir=env --exclude-dir=venv --exclude-dir=.git -lEw "$PLACEHOLDER_DASHES|$PLACEHOLDER_UNDERSCORES" -R * .[^.]*); do
|
for file in $(grep --exclude-dir=env --exclude-dir=venv --exclude-dir=.git --exclude *.pyc -lEw "$PLACEHOLDER_DASHES|$PLACEHOLDER_UNDERSCORES" -R * .[^.]*); do
|
||||||
echo "Checking $file"
|
echo "Checking $file"
|
||||||
if [[ $file != $(basename "$0") ]]; then
|
if [[ $file != $(basename "$0") ]]; then
|
||||||
sed -i "s/$PLACEHOLDER_DASHES/$REPLACEMENT_DASHES/g" $file
|
if is_gnu_sed; then
|
||||||
sed -i "s/$PLACEHOLDER_UNDERSCORES/$REPLACEMENT_UNDERSCORES/g" $file
|
sed -i "s/$PLACEHOLDER_DASHES/$REPLACEMENT_DASHES/g" $file
|
||||||
|
sed -i "s/$PLACEHOLDER_UNDERSCORES/$REPLACEMENT_UNDERSCORES/g" $file
|
||||||
|
else
|
||||||
|
sed -i "" "s/$PLACEHOLDER_DASHES/$REPLACEMENT_DASHES/g" $file
|
||||||
|
sed -i "" "s/$PLACEHOLDER_UNDERSCORES/$REPLACEMENT_UNDERSCORES/g" $file
|
||||||
|
fi
|
||||||
echo " - $file"
|
echo " - $file"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in a new issue