Skip to content

Commit

Permalink
Merge branch 'philip-sed-to-perl-pie'
Browse files Browse the repository at this point in the history
* philip-sed-to-perl-pie:
  Add http:// to Perl APP_URL replacer
  Changed .env replacements to use perl instead of sed
  • Loading branch information
mattstauffer committed Nov 20, 2017
2 parents 54e0595 + 4d51e50 commit 7b849a5
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 @@ -312,30 +312,28 @@ if [ ! -f .env ]; then
cp .env.example .env
fi
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=)(.*)/\1http:\/\/$PROJECTNAME.$TLD/g"
)

if [[ "$LINK" = true ]]; then
valet link "$PROJECTNAME"
fi

for perlCommand in "${perlCommands[@]}"; do
perl -pi -e "$perlCommand" ".env"
done

if [[ "$(uname)" == "Darwin" ]]; then
for sedCommand in "${sedCommands[@]}"; do
sed -i '' "$sedCommand" .env
done
if [[ "$BROWSER" != "" ]]; then
open -a "$BROWSER" "$PROJECTURL"
else
open "$PROJECTURL"
fi
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 7b849a5

Please sign in to comment.