Skip to content

Commit

Permalink
Passthru all arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaquinTrinanes committed Sep 13, 2024
1 parent 9bff06d commit bc553ee
Showing 1 changed file with 26 additions and 28 deletions.
54 changes: 26 additions & 28 deletions bin/sail
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ if [ "$1" == "php" ]; then
if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" "php" "$@")
ARGS+=("$APP_SERVICE" "php")
else
sail_is_not_running
fi
Expand All @@ -222,9 +222,11 @@ elif [ "$1" == "bin" ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
CMD=$1
shift 1
ARGS+=(exec -u sail)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" ./vendor/bin/"$@")
ARGS+=("$APP_SERVICE" ./vendor/bin/"$CMD")
else
sail_is_not_running
fi
Expand All @@ -248,7 +250,7 @@ elif [ "$1" == "composer" ]; then
if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" "composer" "$@")
ARGS+=("$APP_SERVICE" "composer")
else
sail_is_not_running
fi
Expand All @@ -260,7 +262,7 @@ elif [ "$1" == "artisan" ] || [ "$1" == "art" ] || [ "$1" == "a" ]; then
if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" php artisan "$@")
ARGS+=("$APP_SERVICE" php artisan)
else
sail_is_not_running
fi
Expand All @@ -272,7 +274,7 @@ elif [ "$1" == "debug" ]; then
if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail -e XDEBUG_TRIGGER=1)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" php artisan "$@")
ARGS+=("$APP_SERVICE" php artisan)
else
sail_is_not_running
fi
Expand All @@ -284,7 +286,7 @@ elif [ "$1" == "test" ]; then
if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" php artisan test "$@")
ARGS+=("$APP_SERVICE" php artisan test)
else
sail_is_not_running
fi
Expand All @@ -296,7 +298,7 @@ elif [ "$1" == "phpunit" ]; then
if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" php vendor/bin/phpunit "$@")
ARGS+=("$APP_SERVICE" php vendor/bin/phpunit)
else
sail_is_not_running
fi
Expand All @@ -308,7 +310,7 @@ elif [ "$1" == "pest" ]; then
if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" php vendor/bin/pest "$@")
ARGS+=("$APP_SERVICE" php vendor/bin/pest)
else
sail_is_not_running
fi
Expand All @@ -320,7 +322,7 @@ elif [ "$1" == "pint" ]; then
if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" php vendor/bin/pint "$@")
ARGS+=("$APP_SERVICE" php vendor/bin/pint)
else
sail_is_not_running
fi
Expand All @@ -334,7 +336,7 @@ elif [ "$1" == "dusk" ]; then
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=(-e "APP_URL=http://${APP_SERVICE}")
ARGS+=(-e "DUSK_DRIVER_URL=http://selenium:4444/wd/hub")
ARGS+=("$APP_SERVICE" php artisan dusk "$@")
ARGS+=("$APP_SERVICE" php artisan dusk)
else
sail_is_not_running
fi
Expand All @@ -348,13 +350,13 @@ elif [ "$1" == "dusk:fails" ]; then
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=(-e "APP_URL=http://${APP_SERVICE}")
ARGS+=(-e "DUSK_DRIVER_URL=http://selenium:4444/wd/hub")
ARGS+=("$APP_SERVICE" php artisan dusk:fails "$@")
ARGS+=("$APP_SERVICE" php artisan dusk:fails)
else
sail_is_not_running
fi

# Initiate a Laravel Tinker session within the application container...
elif [ "$1" == "tinker" ] ; then
elif [ "$1" == "tinker" ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
Expand All @@ -372,7 +374,7 @@ elif [ "$1" == "node" ]; then
if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" node "$@")
ARGS+=("$APP_SERVICE" node)
else
sail_is_not_running
fi
Expand All @@ -384,7 +386,7 @@ elif [ "$1" == "npm" ]; then
if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" npm "$@")
ARGS+=("$APP_SERVICE" npm)
else
sail_is_not_running
fi
Expand All @@ -396,7 +398,7 @@ elif [ "$1" == "npx" ]; then
if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" npx "$@")
ARGS+=("$APP_SERVICE" npx)
else
sail_is_not_running
fi
Expand All @@ -408,7 +410,7 @@ elif [ "$1" == "pnpm" ]; then
if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" pnpm "$@")
ARGS+=("$APP_SERVICE" pnpm)
else
sail_is_not_running
fi
Expand All @@ -420,7 +422,7 @@ elif [ "$1" == "pnpx" ]; then
if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" pnpx "$@")
ARGS+=("$APP_SERVICE" pnpx)
else
sail_is_not_running
fi
Expand All @@ -432,7 +434,7 @@ elif [ "$1" == "yarn" ]; then
if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" yarn "$@")
ARGS+=("$APP_SERVICE" yarn)
else
sail_is_not_running
fi
Expand All @@ -444,7 +446,7 @@ elif [ "$1" == "bun" ]; then
if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" bun "$@")
ARGS+=("$APP_SERVICE" bun)
else
sail_is_not_running
fi
Expand All @@ -456,7 +458,7 @@ elif [ "$1" == "bunx" ]; then
if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" bunx "$@")
ARGS+=("$APP_SERVICE" bunx)
else
sail_is_not_running
fi
Expand Down Expand Up @@ -507,7 +509,7 @@ elif [ "$1" == "shell" ] || [ "$1" == "bash" ]; then
if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" bash "$@")
ARGS+=("$APP_SERVICE" bash)
else
sail_is_not_running
fi
Expand All @@ -519,13 +521,13 @@ elif [ "$1" == "root-shell" ] || [ "$1" == "root-bash" ]; then
if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u root)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" bash "$@")
ARGS+=("$APP_SERVICE" bash)
else
sail_is_not_running
fi

# Initiate a Redis CLI terminal session within the "redis" container...
elif [ "$1" == "redis" ] ; then
elif [ "$1" == "redis" ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
Expand Down Expand Up @@ -573,11 +575,7 @@ elif [ "$1" == "open" ]; then
else
sail_is_not_running
fi

# Pass unknown commands to the "docker-compose" binary...
else
ARGS+=("$@")
fi

# Run Docker Compose with the defined arguments...
"${DOCKER_COMPOSE[@]}" "${ARGS[@]}"
"${DOCKER_COMPOSE[@]}" "${ARGS[@]}" "$@"

0 comments on commit bc553ee

Please sign in to comment.