Skip to content

Commit 3ea3958

Browse files
authored
Add regex check for correct name (#32)
1 parent 3e8236c commit 3ea3958

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

rename.sh

+19-7
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,24 @@
22

33
read -p 'Project Name: ' projectvar
44

5-
grep -rli 'NEW_NAME' scripts/rename-base.sh | xargs -I@ sed -i '' "s/NEW_NAME/$projectvar/g" @
5+
if [[ "$projectvar" =~ [a-zA-Z_][a-zA-Z_0-9]*$ ]]; then
6+
grep -rli 'NEW_NAME' scripts/rename-base.sh | xargs -I@ sed -i '' "s/NEW_NAME/$projectvar/g" @
7+
8+
sh ./scripts/rename-base.sh
9+
10+
swish appicon
11+
swish xcodeproj
12+
13+
rm -rf scripts
14+
rm rename.sh
15+
else
16+
echo 'Invalid Project Name'
17+
echo ''
18+
echo 'The project name should only include the following characters:'
19+
echo ' - alphanumerics'
20+
echo ' - "_"'
21+
echo ''
22+
echo 'The project name should not start with a number.'
23+
fi
624

7-
sh ./scripts/rename-base.sh
825

9-
swish appicon
10-
swish xcodeproj
11-
12-
rm -rf scripts
13-
rm rename.sh

0 commit comments

Comments
 (0)