Skip to content

Commit

Permalink
Optimize start-dev-env.sh
Browse files Browse the repository at this point in the history
1. The paths specified for mounting the dev envs to are now tested for
   existence. This could be done more elaborately, but for now existence
   testing is convenient enough
2. The foreground/background prompt is streamlined. Hitting enter or
   answering anything but N(no) will run the script in foreground.
  • Loading branch information
MKodde committed Feb 19, 2024
1 parent e66ee7b commit d916bfe
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions stepup/start-dev-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ number_of_dev_envs=0
for arg in "$@"; do
app=$(echo $arg | cut -d ':' -f 1)
path=$(echo $arg | cut -d ':' -f 2)
# Test if the specified path(s) exist. If they do not, halt the script and warn
# the user of this mistake
if [ ! -d ${path} ]; then
# Not going to start the env, so clear the env listing
rm .start-dev-env-listing
echo -e "The specified path for app '${app}' is not a directory. \n";
echo -e "Please review: '${path}'";
exit 1;
fi
echo "export ${app^^}_CODE_PATH=${path}" >>.start-dev-env-vars
# Keep a listing of all apps that are started in dev mode, for feedback purposes
echo "${app^^}: ${path}" >>.start-dev-env-listing
Expand All @@ -39,17 +48,16 @@ rm .start-dev-env-listing
echo -e "Starting the dev environment with the following command:\n"

while true; do
read -p "Do you wish to run Docker compose in the foreground? " yn
read -p "Do you wish to run Docker compose in the foreground? (press ENTER for Yes) " yn
case $yn in
[Yy]* )
echo -e "docker compose -f docker-compose.yml "${docker_compose_args[@]}" "${extra_compose_args}" up "${@:$number_of_dev_envs}"\n"
docker compose -f docker-compose.yml ${docker_compose_args[@]} ${extra_compose_args} up "${@:$number_of_dev_envs}"
break;;
[Nn]* )
echo -e "docker compose -f docker-compose.yml "${docker_compose_args[@]}" "${extra_compose_args}" up -d "${@:$number_of_dev_envs}"\n"
docker compose -f docker-compose.yml ${docker_compose_args[@]} ${extra_compose_args} up -d "${@:$number_of_dev_envs}"
break;;
* ) echo "Please answer yes or no.";;
* )
echo -e "docker compose -f docker-compose.yml "${docker_compose_args[@]}" "${extra_compose_args}" up "${@:$number_of_dev_envs}"\n"
docker compose -f docker-compose.yml ${docker_compose_args[@]} ${extra_compose_args} up "${@:$number_of_dev_envs}"
break;;
esac
done

0 comments on commit d916bfe

Please sign in to comment.