From 3869b944cfc91d029ec0560ae438e3f37dd19194 Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Sun, 23 Jun 2024 00:56:58 -0300 Subject: [PATCH] Update host/bin/setup --- host/bin/setup | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/host/bin/setup b/host/bin/setup index 442b8b8..101eaeb 100755 --- a/host/bin/setup +++ b/host/bin/setup @@ -1,17 +1,45 @@ #!/bin/sh -# About: -# bin/setup installs rubygem & npm dependencies in each -# sub-directory / sub-package (cli, client, server). set -e -wrkdir=$(pwd) + +## +# functions +printok() +{ + echo "ok: ${1}" > /dev/stdout +} + +printerr() +{ + echo "error: ${1}" > /dev/stderr +} + +require_dependency() +{ + for i in $(seq 1 $#); do + eval "cmd=\$${i}" + if which ${cmd} > /dev/null 2>&1; then + printok "${cmd} found" + else + printerr "${cmd} is required but was not found on \$PATH" + exit 1 + fi + done +} + +## +# main +require_dependency git bundle npm subdir=". cli client server" +cwd=$(pwd) for dir in ${subdir}; do - cd ${dir} + cd "${dir}" bundle install + printok "ruby dependencies installed" if [ -e "package.json" ]; then npm i + printok "nodejs dependencies installed" fi - cd ${wrkdir} + cd "${cwd}" done git submodule update --init --recursive -echo OK +printok "submodules checked out"