Skip to content

Commit 20fdceb

Browse files
Jasonejerik-perri
andauthored
Hop improvements (#52)
* update: pass through args to dss command when running up to allow for --force-recreate and --remove-orphans Co-authored-by: Erik Perri <erik.perri@sourcetoad.com> * update: add hop go utility Co-authored-by: Erik Perri <erik.perri@sourcetoad.com> * style: fix lint Co-authored-by: Erik Perri <erik.perri@sourcetoad.com> * update: remove unneeded if check because yarn also supports using run Co-authored-by: Erik Perri <erik.perri@sourcetoad.com> * update: stop running up during go if not needed Co-authored-by: Jason Jones <jason@sourcetoad.com> --------- Co-authored-by: Erik Perri <erik.perri@sourcetoad.com>
1 parent accf4b4 commit 20fdceb

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

bin/hop

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ function display_help {
111111
echo
112112
tag "$BG_Y$BOLD" "Docker Commands"
113113
describe_command "up" "Start the containers"
114-
describe_command "up" "-d" "Start the contains in the background"
114+
describe_command "up" "-d" "\$@" "Start the contains in the background"
115115
describe_command "stop" "Stop the containers"
116116
describe_command "down" "Stop and remove the containers"
117117
describe_command "restart" "Restart the containers"
@@ -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,13 @@ 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" "run")
323+
308324
case $1 in
309325
"app:"*|"build:"*|"db:"*|"make:"*|"migrate:"*|"queue:"*)
310326
run_exec_command php artisan "$@"
@@ -336,6 +352,17 @@ case $1 in
336352
shift 1
337353
run_exec_command php artisan migrate:fresh "$@"
338354
;;
355+
"go")
356+
shift 1
357+
if [ "$EXEC" == "no" ]; then
358+
run_hop_command up -d
359+
fi
360+
if [ -z "$*" ]; then
361+
run_hop_command "${PACKAGE_MANAGER_RUN_CMD[@]}" "dev"
362+
else
363+
run_hop_command "${PACKAGE_MANAGER_RUN_CMD[@]}" "$@"
364+
fi
365+
;;
339366
"migrate")
340367
shift 1
341368
run_exec_command php artisan migrate "$@"
@@ -402,7 +429,7 @@ case $1 in
402429
;;
403430
"up")
404431
shift 1
405-
run_dss_command up -d
432+
run_dss_command up -d "$@"
406433
run_command up "$@"
407434
;;
408435
"yarn")

0 commit comments

Comments
 (0)