Skip to content

Commit

Permalink
πŸ› FIX: #98 and #93
Browse files Browse the repository at this point in the history
  • Loading branch information
apolopena committed Apr 10, 2021
1 parent 4ff0fe3 commit 58ca867
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 56 deletions.
8 changes: 4 additions & 4 deletions .gitpod.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ COPY --chown=gitpod:gitpod .gp/bash/scaffold-project.sh /tmp
RUN sudo bash -c ". /tmp/scaffold-project.sh" && rm /tmp/scaffold-project.sh

# Aliases
COPY --chown=gitpod:gitpod .gp/bash/snippets/server-functions /tmp
COPY --chown=gitpod:gitpod .gp/bash/snippets/browser-functions /tmp
RUN cp /tmp/server-functions ~/.bashrc.d/server-functions \
&& cp /tmp/browser-functions ~/.bashrc.d/browser-functions
COPY --chown=gitpod:gitpod .gp/bash/snippets/server-functions.sh /tmp
COPY --chown=gitpod:gitpod .gp/bash/snippets/browser-functions.sh /tmp
RUN cp /tmp/server-functions.sh ~/.bashrc.d/server-functions \
&& cp /tmp/browser-functions.sh ~/.bashrc.d/browser-functions
52 changes: 0 additions & 52 deletions .gp/bash/snippets/browser-functions

This file was deleted.

54 changes: 54 additions & 0 deletions .gp/bash/snippets/browser-functions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# shellcheck shell=bash
server_port() {
local err='Error: get_server_port():'
case $(echo "$1" | tr '[:upper:]' '[:lower:]') in
'php')
echo 8000
;;
'apache')
echo 8001
;;
'nginx')
echo 8002
;;
*)
echo 8001 ; exit 1
;;
esac
}

debug_on() {
local refresh stype port
local usage='Usage: debug_on server-type [no-refresh]'
local err='Error: debug_on():'
refresh=$(echo "$2" | tr '[:upper:]' '[:lower:]')
stype=$(echo "$1" | tr '[:upper:]' '[:lower:]')
# Error handling
[ -z "$stype" ] && echo "$err must have at least one argument" && echo "$usage" && return
[[ $stype != 'php' && $stype != 'apache' && $stype != 'nginx' ]] \
&& echo -e "$err Invalid default server type $stype.\nCheck starter.ini for supported values" && return
[ "$refresh" != '' ] && [ "$refresh" != 'no-refresh' ] && echo "$err invalid refresh argument: $refresh" && return
# Set port
if ! port=$(server_port stype); then echo "Internal $err server_port() defaulted to $port"; fi
# Start debug session
[ "$refresh" == 'no-refresh' ] && gp preview "$(gp url "$port")?XDEBUG_SESSION_START=$stype" && return
gp preview "$(gp url "$port")?XDEBUG_SESSION_START=$stype" && sleep 1 && gp preview "$(gp url "$port")"
}

debug_off() {
local refresh stype port
local usage='Usage: debug_off server-type [no-refresh]'
local err='Error: debug_off():'
refresh=$(echo "$2" | tr '[:upper:]' '[:lower:]')
stype=$(echo "$1" | tr '[:upper:]' '[:lower:]')
# Error handling
[ -z "$stype" ] && echo "$err must have at least one argument" && echo "$usage" && return
[[ $stype != 'php' && $stype != 'apache' && $stype != 'nginx' ]] \
&& echo -e "$err Invalid default server type $stype.\nCheck starter.ini for supported values" && return
[ "$refresh" != '' ] && [ "$refresh" != 'no-refresh' ] && echo "$err invalid refresh argument: $refresh" && return
# Set port
if ! port=$(server_port stype); then echo "Internal $err server_port() defaulted to $port"; fi
# Stop debug session
[ "$refresh" == 'no-refresh' ] && gp preview "$(gp url "$port")?XDEBUG_SESSION_STOP=$stype" && return
gp preview "$(gp url "$port")?XDEBUG_SESSION_STOP=$stype" && sleep 1 && gp preview "$(gp url "$port")"
}
File renamed without changes.

0 comments on commit 58ca867

Please sign in to comment.