Skip to content

Commit 8ba393b

Browse files
committed
refactor: remove duplication in setup script
The executable variable definitions were duplicated for each container type so they could be prefixed with the necessary commands to run the executable from within the container. the `$RUN` variable already had this command set for each container type, so use that universally instead.
1 parent e3fb9b1 commit 8ba393b

File tree

1 file changed

+15
-49
lines changed

1 file changed

+15
-49
lines changed

bin/setup

Lines changed: 15 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -223,55 +223,21 @@ if [ ! -d ${ROOT}/node_modules ]; then
223223
${RUN} npm i
224224
fi
225225

226-
if [ "${CONTAINER_TYPE}" == "devcontainer" ]; then
227-
BUNDLE="bundle"
228-
RUBY="bundle exec ruby"
229-
RAKE="bundle exec rake"
230-
NPM="npm"
231-
NPX="npx"
232-
NODE="node"
233-
PYTHON="${ROOT}/.home/.venv/bin/python3"
234-
PIP="${ROOT}/.home/.venv/bin/pip"
235-
BASH="bash"
236-
GPP="g++"
237-
GDB="gdb"
238-
CLANG_FORMAT="clang-format"
239-
CLANG_TIDY="clang-tidy"
240-
MAKE="make"
241-
elif [ "${CONTAINER_TYPE}" == "docker" -o "${CONTAINER_TYPE}" == "podman" ]; then
242-
BUNDLE="${CONTAINER_BASE} bundle"
243-
RUBY="${CONTAINER_BASE} bundle exec ruby"
244-
RAKE="${CONTAINER_BASE} bundle exec rake"
245-
NPM="${CONTAINER_BASE} npm"
246-
NPX="${CONTAINER_BASE} npx"
247-
NODE="${CONTAINER_BASE} node"
248-
PYTHON="${CONTAINER_BASE} ${ROOT}/.home/.venv/bin/python3"
249-
PIP="${CONTAINER_BASE} ${ROOT}/.home/.venv/bin/pip"
250-
BASH="${CONTAINER_BASE} bash"
251-
GPP="${CONTAINER_BASE} g++"
252-
GDB="${CONTAINER_BASE} gdb"
253-
CLANG_FORMAT="${CONTAINER_BASE} clang-format"
254-
CLANG_TIDY="${CONTAINER_BASE} clang-tidy"
255-
MAKE="${CONTAINER_BASE} make"
256-
elif [ "${CONTAINER_TYPE}" == "singularity" ]; then
257-
BUNDLE="singularity run ${HOME_OPT} ${CONTAINER_PATH} bundle"
258-
RUBY="singularity run ${HOME_OPT} ${CONTAINER_PATH} bundle exec ruby"
259-
RAKE="singularity run ${HOME_OPT} ${CONTAINER_PATH} bundle exec rake"
260-
NPM="singularity run ${HOME_OPT} ${CONTAINER_PATH} npm"
261-
NPX="singularity run ${HOME_OPT} ${CONTAINER_PATH} npx"
262-
NODE="singularity run ${HOME_OPT} ${CONTAINER_PATH} node"
263-
PYTHON="singularity run ${HOME_OPT} ${CONTAINER_PATH} ${ROOT}/.home/.venv/bin/python3"
264-
PIP="singularity run ${HOME_OPT} ${CONTAINER_PATH} ${ROOT}/.home/.venv/bin/pip"
265-
BASH="singularity run ${HOME_OPT} ${CONTAINER_PATH} bash"
266-
GPP="singularity run ${HOME_OPT} ${CONTAINER_PATH} g++"
267-
GDB="singularity run ${HOME_OPT} ${CONTAINER_PATH} gdb"
268-
CLANG_FORMAT="singularity run ${HOME_OPT} ${CONTAINER_PATH} clang-format"
269-
CLANG_TIDY="singularity run ${HOME_OPT} ${CONTAINER_PATH} clang-tidy"
270-
MAKE="singularity run ${HOME_OPT} ${CONTAINER_PATH} make"
271-
else
272-
echo "Bad container type: ${CONTAINER_TYPE}" 1>&2
273-
exit 1
274-
fi
226+
# Set executables
227+
BUNDLE="${RUN} bundle"
228+
RUBY="${RUN} bundle exec ruby"
229+
RAKE="${RUN} bundle exec rake"
230+
NPM="${RUN} npm"
231+
NPX="${RUN} npx"
232+
NODE="${RUN} node"
233+
PYTHON="${RUN} ${ROOT}/.home/.venv/bin/python3"
234+
PIP="${RUN} ${ROOT}/.home/.venv/bin/pip"
235+
BASH="${RUN} bash"
236+
GPP="${RUN} g++"
237+
GDB="${RUN} gdb"
238+
CLANG_FORMAT="${RUN} clang-format"
239+
CLANG_TIDY="${RUN} clang-tidy"
240+
MAKE="${RUN} make"
275241

276242
git config --local commit.template ${ROOT}/.gitmessage
277243

0 commit comments

Comments
 (0)