Skip to content

Commit f2f6d0a

Browse files
Jasonejerik-perri
andcommitted
update: add hop go utility
Co-authored-by: Erik Perri <erik.perri@sourcetoad.com>
1 parent dd5247d commit f2f6d0a

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

bin/hop

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ function display_help {
134134
echo
135135
tag "$BG_Y$BOLD" "Utilities"
136136
describe_command "explain" "Output the command that would be executed by hop"
137+
describe_command "go" "\$@" "Start the container and run \"yarn/npm run\" {command} (default dev)"
137138
describe_command "in" "Start a shell session within the project's code container"
138139
echo
139140
tag "$BG_Y$BOLD" "Aliases"
@@ -246,6 +247,14 @@ fi
246247
# Running Commands
247248
#
248249

250+
function run_hop_command {
251+
if [ "$EXPLAIN" == "yes" ]; then
252+
explain hop "$@"
253+
else
254+
hop "$@"
255+
fi
256+
}
257+
249258
function run_command {
250259
if [ "$EXPLAIN" == "yes" ]; then
251260
explain "${DOCKER_COMPOSE[@]}" "$@"
@@ -305,6 +314,16 @@ if [ "$1" == "explain" ]; then
305314
shift 1
306315
fi
307316

317+
PACKAGE_MANAGER="npm"
318+
if [ -f "yarn.lock" ]; then
319+
PACKAGE_MANAGER="yarn"
320+
fi
321+
322+
PACKAGE_MANAGER_RUN_CMD=("$PACKAGE_MANAGER")
323+
if [ "$PACKAGE_MANAGER" == "npm" ]; then
324+
PACKAGE_MANAGER_RUN_CMD+=("run")
325+
fi
326+
308327
case $1 in
309328
"app:"*|"build:"*|"db:"*|"make:"*|"migrate:"*|"queue:"*)
310329
run_exec_command php artisan "$@"
@@ -336,6 +355,15 @@ case $1 in
336355
shift 1
337356
run_exec_command php artisan migrate:fresh "$@"
338357
;;
358+
"go")
359+
shift 1
360+
run_hop_command up -d
361+
if [ -z "$@" ]; then
362+
run_hop_command "${PACKAGE_MANAGER_RUN_CMD[@]}" "dev"
363+
else
364+
run_hop_command "${PACKAGE_MANAGER_RUN_CMD[@]}" "$@"
365+
fi
366+
;;
339367
"migrate")
340368
shift 1
341369
run_exec_command php artisan migrate "$@"

0 commit comments

Comments
 (0)