I made a mistake to naming some components, I don't want to erase it and create again, the problem is, I need to rename the files by hand, it's a boring task, and maybe in the future I will get the same issue, to make me the life easier I developed the following snippet, you should use it if you have the same problem.
#!/usr/bin/env bash
# purpose: rename files, in same path
# if you make a mistake to defining the name of ember component,
# and you want to rename the files. This snippet is for you.
# NOTE: You should change the component calls in your code,
# this feature is not implemented yet.
# For DEBUG purposes uncomment the following line:
# set -x
if [ ! -z $1 ] && [ ! -z $2 ]
then
NAME="$1"
RENAME="$2"
for i in $(find . -path ./tmp -prune -o -name "${NAME}*")
do
if [[ $i != "./tmp" ]]
then
OUT=$(echo $i | sed -e "s/${NAME}/${RENAME}/g")
echo "rename $i to $OUT"
mv $i $OUT
fi
done
else
echo "You must specify the NAME and RENAME parameters to rename the file";
fi
The output looks like this:
./rename.sh section-medium section-index-medium
rename ./app/components/layers/section-medium.js to ./app/components/layers/section-index-medium.js
rename ./app/templates/components/layers/section-medium.hbs to ./app/templates/components/layers/section-index-medium.hbs
rename ./tests/integration/components/layers/section-medium-test.js to ./tests/integration/components/layers/section-index-medium-test.js
NOTE: put the snipped in your root project.
/your-project/app
/your-project/config
/your-project/...
/your-project/ember-cli-build.js
/your-project/rename.sh
.... and so on