forked from OdinWermeille/mimms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrenameImportInPages.sh
More file actions
42 lines (24 loc) · 841 Bytes
/
renameImportInPages.sh
File metadata and controls
42 lines (24 loc) · 841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
CURRENT=$1; shift
NEW=$1; shift
OPT=$1; shift;
if [ -z "$CURRENT" ]; then
echo please provide args
exit -1;
fi
if [ -z "$NEW" ]; then
echo please provide args
exit -1;
fi
ESC_CURRENT=`echo $CURRENT | sed -e "s|/|\\\\\/|g"`
ESC_NEW=`echo $NEW | sed -e "s|/|\\\\\/|g"`
echo move $CURRENT to $NEW
echo Escaped: $ESC_CURRENT to $ESC_NEW
# OCCURENCES=`grep -o -P "import (.*?) from ('|\\\\\")\./${CURRENT}('|\\\\\")" -l * | xargs`
OCCURENCES=`grep -o -P "import (.*?) from ('|\\\\\\\\\")\\.\\/${ESC_CURRENT}('|\\\\\\\\\")" gameModel/pages/* -l | xargs`
if [ -z "$OCCURENCES" ]; then
echo No occurence found
exit -1;
fi
echo OCCURENCES: ${OCCURENCES}
perl -p${OPT} -e "s/import (.*?) from ('|\\\\\")\.\/${ESC_CURRENT}('|\\\\\")/import \1 from '.\/${ESC_NEW}'/" ${OCCURENCES} | grep ${ESC_NEW}