-
Notifications
You must be signed in to change notification settings - Fork 3
/
copy.sh
executable file
·29 lines (27 loc) · 1.07 KB
/
copy.sh
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
#!/bin/bash
# Copy the boilerplate to the target
cp -rf templates/fragment src/$1
echo "$FUN_FRAGMENT_NAME $FUN_PORT" >> registry
# cp -rf templates/boilerplate src/$1
cd src/$1
mv components/component.js components/$FUN_FRAGMENT_NAME.js
# Author of script: https://github.com/cagataycali
# Original source: https://gist.github.com/cagataycali/917a90113aa7ac4819114fd45d9e0d2c
prefix="FUN_"
# Usage: FUN_PROVIDER='test' FUN_CAGATAY='CALI' ./replace.sh
# echo $FUN_DIRNAME
# The for loop below is taken from here:
# https://stackoverflow.com/questions/39529648/how-to-iterate-through-all-the-env-variables-printing-key-and-value
unset IFS
for var in "${!FUN_@}"; do
glob="s|#$var|${!var}|g"
# Debug with uncomment below echo.
# echo $glob # Will replace if the FUN_PROVIDER='TEST'
# The find code is taken from: https://superuser.com/a/537037
find . -type f -name "*" -not -path '*/\.git/*' -not -path '*/\node_modules/*' -exec sed -i'' -e $glob {} + 2> /dev/null
done
rm **/*-e 2> /dev/null
rm *-e 2> /dev/null
rm **/.*-e 2> /dev/null
rm .*-e 2> /dev/null
echo 'Cleanup success'