Skip to content

Commit b8adfbf

Browse files
committed
LPD-73748 lec.sh: require directories in helper functions
1 parent 6037cbd commit b8adfbf

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

scripts/cli/lec.sh

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -411,22 +411,25 @@ _verifyListableEntity() {
411411
#
412412

413413
_getComposeProjectName() {
414-
_checkCWDProject
414+
local projectDir="${1}"
415415

416-
echo "${CWD_PROJECT_ROOT##*/}" | tr "[:upper:]" "[:lower:]"
416+
echo "${projectDir##*/}" | tr "[:upper:]" "[:lower:]"
417417
}
418418
_getServicePorts() {
419-
_checkCWDProject
420-
421-
local serviceName="${1}"
419+
local projectDir="${1}"
420+
local serviceName="${2}"
422421
# shellcheck disable=SC2016
423422
local template='table NAME\tCONTAINER PORT\tHOST PORT\n{{$name := .Name}}{{range .Publishers}}{{if eq .URL "0.0.0.0"}}{{$name}}\t{{.TargetPort}}\tlocalhost:{{.PublishedPort}}\n{{end}}{{end}}'
424423

425-
if [[ "${serviceName}" ]]; then
426-
docker compose ps "${serviceName}" --format "${template}" | tail -n +3
427-
else
428-
docker compose ps --format "${template}" | tail -n +3
429-
fi
424+
(
425+
cd "${projectDir}" || exit 1
426+
427+
if [[ "${serviceName}" ]]; then
428+
docker compose ps "${serviceName}" --format "${template}" | tail -n +3
429+
else
430+
docker compose ps --format "${template}" | tail -n +3
431+
fi
432+
)
430433
}
431434
_getWorktreeDir() {
432435
local worktree_name="${1}"

0 commit comments

Comments
 (0)