Last active
August 17, 2016 08:13
-
-
Save yunghoy/19a43467a977cd946b08cf92d5cd0bb1 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
#!/bin/bash | |
SOURCEDIR=utils | |
TARGETDIR=util | |
pushd be > /dev/null | |
SERVICES="$(ls -d *-island)" | |
popd > /dev/null | |
for SERVICE in ${SERVICES}; do | |
pushd be/${SERVICE}/src > /dev/null | |
if [ -d SOURCEDIR ]; then | |
echo "--------------------------------------------------" | |
echo "Modifying the island: ${SERVICE}" | |
# type your command | |
rsync -avm --include='*.ts' -f 'hide,! */' ${SOURCEDIR}/ ${TARGETDIR} | |
rm -rf ${SOURCEDIR} | |
grep -rl "\/${SOURCEDIR}" | grep -E "\.ts$|\.js$" | grep -vE "node_modules|typings|externals" | xargs sed -i -r "s/^(import.*)(\/${SOURCEDIR})(.*)/\1\/${TARGETDIR}\3/g" | |
grep -rl "${SOURCEDIR}\/" | grep -E "\.ts$|\.js$" | grep -vE "node_modules|typings|externals" | xargs sed -i -r "s/^(import.*)(${SOURCEDIR}\/)(.*)/\1${TARGETDIR}\/\3/g" | |
grep -rl "\/${SOURCEDIR}\/" | grep -E "\.ts$|\.js$" | grep -vE "node_modules|typings|externals" | xargs sed -i -r "s/^(import.*)(\/${SOURCEDIR}\/)(.*)/\1\/${TARGETDIR}\/\3/g" | |
# end of your command | |
fi | |
popd > /dev/null | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
!/bin/bash
SOURCEDIR=$1
TARGETDIR=$2
echo "--------------------------------------------------"
echo "Modifying the island: ${SERVICE}"