Skip to content

Commit 2bc15bf

Browse files
Passthru all arguments (#728)
1 parent 9bff06d commit 2bc15bf

File tree

1 file changed

+26
-28
lines changed

1 file changed

+26
-28
lines changed

bin/sail

+26-28
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ if [ "$1" == "php" ]; then
212212
if [ "$EXEC" == "yes" ]; then
213213
ARGS+=(exec -u sail)
214214
[ ! -t 0 ] && ARGS+=(-T)
215-
ARGS+=("$APP_SERVICE" "php" "$@")
215+
ARGS+=("$APP_SERVICE" "php")
216216
else
217217
sail_is_not_running
218218
fi
@@ -222,9 +222,11 @@ elif [ "$1" == "bin" ]; then
222222
shift 1
223223

224224
if [ "$EXEC" == "yes" ]; then
225+
CMD=$1
226+
shift 1
225227
ARGS+=(exec -u sail)
226228
[ ! -t 0 ] && ARGS+=(-T)
227-
ARGS+=("$APP_SERVICE" ./vendor/bin/"$@")
229+
ARGS+=("$APP_SERVICE" ./vendor/bin/"$CMD")
228230
else
229231
sail_is_not_running
230232
fi
@@ -248,7 +250,7 @@ elif [ "$1" == "composer" ]; then
248250
if [ "$EXEC" == "yes" ]; then
249251
ARGS+=(exec -u sail)
250252
[ ! -t 0 ] && ARGS+=(-T)
251-
ARGS+=("$APP_SERVICE" "composer" "$@")
253+
ARGS+=("$APP_SERVICE" "composer")
252254
else
253255
sail_is_not_running
254256
fi
@@ -260,7 +262,7 @@ elif [ "$1" == "artisan" ] || [ "$1" == "art" ] || [ "$1" == "a" ]; then
260262
if [ "$EXEC" == "yes" ]; then
261263
ARGS+=(exec -u sail)
262264
[ ! -t 0 ] && ARGS+=(-T)
263-
ARGS+=("$APP_SERVICE" php artisan "$@")
265+
ARGS+=("$APP_SERVICE" php artisan)
264266
else
265267
sail_is_not_running
266268
fi
@@ -272,7 +274,7 @@ elif [ "$1" == "debug" ]; then
272274
if [ "$EXEC" == "yes" ]; then
273275
ARGS+=(exec -u sail -e XDEBUG_TRIGGER=1)
274276
[ ! -t 0 ] && ARGS+=(-T)
275-
ARGS+=("$APP_SERVICE" php artisan "$@")
277+
ARGS+=("$APP_SERVICE" php artisan)
276278
else
277279
sail_is_not_running
278280
fi
@@ -284,7 +286,7 @@ elif [ "$1" == "test" ]; then
284286
if [ "$EXEC" == "yes" ]; then
285287
ARGS+=(exec -u sail)
286288
[ ! -t 0 ] && ARGS+=(-T)
287-
ARGS+=("$APP_SERVICE" php artisan test "$@")
289+
ARGS+=("$APP_SERVICE" php artisan test)
288290
else
289291
sail_is_not_running
290292
fi
@@ -296,7 +298,7 @@ elif [ "$1" == "phpunit" ]; then
296298
if [ "$EXEC" == "yes" ]; then
297299
ARGS+=(exec -u sail)
298300
[ ! -t 0 ] && ARGS+=(-T)
299-
ARGS+=("$APP_SERVICE" php vendor/bin/phpunit "$@")
301+
ARGS+=("$APP_SERVICE" php vendor/bin/phpunit)
300302
else
301303
sail_is_not_running
302304
fi
@@ -308,7 +310,7 @@ elif [ "$1" == "pest" ]; then
308310
if [ "$EXEC" == "yes" ]; then
309311
ARGS+=(exec -u sail)
310312
[ ! -t 0 ] && ARGS+=(-T)
311-
ARGS+=("$APP_SERVICE" php vendor/bin/pest "$@")
313+
ARGS+=("$APP_SERVICE" php vendor/bin/pest)
312314
else
313315
sail_is_not_running
314316
fi
@@ -320,7 +322,7 @@ elif [ "$1" == "pint" ]; then
320322
if [ "$EXEC" == "yes" ]; then
321323
ARGS+=(exec -u sail)
322324
[ ! -t 0 ] && ARGS+=(-T)
323-
ARGS+=("$APP_SERVICE" php vendor/bin/pint "$@")
325+
ARGS+=("$APP_SERVICE" php vendor/bin/pint)
324326
else
325327
sail_is_not_running
326328
fi
@@ -334,7 +336,7 @@ elif [ "$1" == "dusk" ]; then
334336
[ ! -t 0 ] && ARGS+=(-T)
335337
ARGS+=(-e "APP_URL=http://${APP_SERVICE}")
336338
ARGS+=(-e "DUSK_DRIVER_URL=http://selenium:4444/wd/hub")
337-
ARGS+=("$APP_SERVICE" php artisan dusk "$@")
339+
ARGS+=("$APP_SERVICE" php artisan dusk)
338340
else
339341
sail_is_not_running
340342
fi
@@ -348,13 +350,13 @@ elif [ "$1" == "dusk:fails" ]; then
348350
[ ! -t 0 ] && ARGS+=(-T)
349351
ARGS+=(-e "APP_URL=http://${APP_SERVICE}")
350352
ARGS+=(-e "DUSK_DRIVER_URL=http://selenium:4444/wd/hub")
351-
ARGS+=("$APP_SERVICE" php artisan dusk:fails "$@")
353+
ARGS+=("$APP_SERVICE" php artisan dusk:fails)
352354
else
353355
sail_is_not_running
354356
fi
355357

356358
# Initiate a Laravel Tinker session within the application container...
357-
elif [ "$1" == "tinker" ] ; then
359+
elif [ "$1" == "tinker" ]; then
358360
shift 1
359361

360362
if [ "$EXEC" == "yes" ]; then
@@ -372,7 +374,7 @@ elif [ "$1" == "node" ]; then
372374
if [ "$EXEC" == "yes" ]; then
373375
ARGS+=(exec -u sail)
374376
[ ! -t 0 ] && ARGS+=(-T)
375-
ARGS+=("$APP_SERVICE" node "$@")
377+
ARGS+=("$APP_SERVICE" node)
376378
else
377379
sail_is_not_running
378380
fi
@@ -384,7 +386,7 @@ elif [ "$1" == "npm" ]; then
384386
if [ "$EXEC" == "yes" ]; then
385387
ARGS+=(exec -u sail)
386388
[ ! -t 0 ] && ARGS+=(-T)
387-
ARGS+=("$APP_SERVICE" npm "$@")
389+
ARGS+=("$APP_SERVICE" npm)
388390
else
389391
sail_is_not_running
390392
fi
@@ -396,7 +398,7 @@ elif [ "$1" == "npx" ]; then
396398
if [ "$EXEC" == "yes" ]; then
397399
ARGS+=(exec -u sail)
398400
[ ! -t 0 ] && ARGS+=(-T)
399-
ARGS+=("$APP_SERVICE" npx "$@")
401+
ARGS+=("$APP_SERVICE" npx)
400402
else
401403
sail_is_not_running
402404
fi
@@ -408,7 +410,7 @@ elif [ "$1" == "pnpm" ]; then
408410
if [ "$EXEC" == "yes" ]; then
409411
ARGS+=(exec -u sail)
410412
[ ! -t 0 ] && ARGS+=(-T)
411-
ARGS+=("$APP_SERVICE" pnpm "$@")
413+
ARGS+=("$APP_SERVICE" pnpm)
412414
else
413415
sail_is_not_running
414416
fi
@@ -420,7 +422,7 @@ elif [ "$1" == "pnpx" ]; then
420422
if [ "$EXEC" == "yes" ]; then
421423
ARGS+=(exec -u sail)
422424
[ ! -t 0 ] && ARGS+=(-T)
423-
ARGS+=("$APP_SERVICE" pnpx "$@")
425+
ARGS+=("$APP_SERVICE" pnpx)
424426
else
425427
sail_is_not_running
426428
fi
@@ -432,7 +434,7 @@ elif [ "$1" == "yarn" ]; then
432434
if [ "$EXEC" == "yes" ]; then
433435
ARGS+=(exec -u sail)
434436
[ ! -t 0 ] && ARGS+=(-T)
435-
ARGS+=("$APP_SERVICE" yarn "$@")
437+
ARGS+=("$APP_SERVICE" yarn)
436438
else
437439
sail_is_not_running
438440
fi
@@ -444,7 +446,7 @@ elif [ "$1" == "bun" ]; then
444446
if [ "$EXEC" == "yes" ]; then
445447
ARGS+=(exec -u sail)
446448
[ ! -t 0 ] && ARGS+=(-T)
447-
ARGS+=("$APP_SERVICE" bun "$@")
449+
ARGS+=("$APP_SERVICE" bun)
448450
else
449451
sail_is_not_running
450452
fi
@@ -456,7 +458,7 @@ elif [ "$1" == "bunx" ]; then
456458
if [ "$EXEC" == "yes" ]; then
457459
ARGS+=(exec -u sail)
458460
[ ! -t 0 ] && ARGS+=(-T)
459-
ARGS+=("$APP_SERVICE" bunx "$@")
461+
ARGS+=("$APP_SERVICE" bunx)
460462
else
461463
sail_is_not_running
462464
fi
@@ -507,7 +509,7 @@ elif [ "$1" == "shell" ] || [ "$1" == "bash" ]; then
507509
if [ "$EXEC" == "yes" ]; then
508510
ARGS+=(exec -u sail)
509511
[ ! -t 0 ] && ARGS+=(-T)
510-
ARGS+=("$APP_SERVICE" bash "$@")
512+
ARGS+=("$APP_SERVICE" bash)
511513
else
512514
sail_is_not_running
513515
fi
@@ -519,13 +521,13 @@ elif [ "$1" == "root-shell" ] || [ "$1" == "root-bash" ]; then
519521
if [ "$EXEC" == "yes" ]; then
520522
ARGS+=(exec -u root)
521523
[ ! -t 0 ] && ARGS+=(-T)
522-
ARGS+=("$APP_SERVICE" bash "$@")
524+
ARGS+=("$APP_SERVICE" bash)
523525
else
524526
sail_is_not_running
525527
fi
526528

527529
# Initiate a Redis CLI terminal session within the "redis" container...
528-
elif [ "$1" == "redis" ] ; then
530+
elif [ "$1" == "redis" ]; then
529531
shift 1
530532

531533
if [ "$EXEC" == "yes" ]; then
@@ -573,11 +575,7 @@ elif [ "$1" == "open" ]; then
573575
else
574576
sail_is_not_running
575577
fi
576-
577-
# Pass unknown commands to the "docker-compose" binary...
578-
else
579-
ARGS+=("$@")
580578
fi
581579

582580
# Run Docker Compose with the defined arguments...
583-
"${DOCKER_COMPOSE[@]}" "${ARGS[@]}"
581+
"${DOCKER_COMPOSE[@]}" "${ARGS[@]}" "$@"

0 commit comments

Comments
 (0)