Skip to content

Commit

Permalink
Changed .env replacements to use perl instead of sed
Browse files Browse the repository at this point in the history
  • Loading branch information
philip committed Mar 28, 2017
1 parent f77a4ea commit 843ef4a
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions lambo
Original file line number Diff line number Diff line change
Expand Up @@ -139,22 +139,20 @@ fi
# Update .env to point to this database with `root` username and blank pw,
# like Mac MySQL defaults, and appropriate domain
PROJECTURL="http://$PROJECTNAME.$TLD"
sedCommands=(
"/DB_DATABASE/s/homestead/$PROJECTNAME/"
'/DB_USERNAME/s/homestead/root/'
'/DB_PASSWORD/s/secret//'
"/APP_URL/s/localhost/$PROJECTNAME\.$TLD/"
perlCommands=(
"s/(DB_DATABASE=)(.*)/\1$PROJECTNAME/g"
's/(DB_USERNAME=)(.*)/\1root/g'
's/(DB_PASSWORD=)(.*)/\1/g'
"s/(APP_URL=)(.*)/\1$PROJECTNAME\.$TLD/g"
)

if [[ "$(uname)" == "Darwin" ]]; then
for sedCommand in "${sedCommands[@]}"; do
sed -i '' "$sedCommand" .env
for perlCommand in "${perlCommands[@]}"; do
perl -pi -e "$perlCommand" ".env"
done

if [[ "$(uname)" == "Darwin" ]]; then
open "$PROJECTURL"
elif [[ "$(expr substr $(uname -s) 1 5)" == "Linux" ]]; then
for sedCommand in "${sedCommands[@]}"; do
sed -i "$sedCommand" .env
done
xdg-open "$PROJECTURL"
fi

Expand Down

0 comments on commit 843ef4a

Please sign in to comment.