Skip to content

Commit db0294a

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 7d94f86 commit db0294a

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
@@ -209,55 +209,21 @@ if [[ ! -z "$DEVELOPMENT" && $DEVELOPMENT -eq 1 ]]; then
209209
fi
210210
fi
211211

212-
if [ "${CONTAINER_TYPE}" == "devcontainer" ]; then
213-
BUNDLE="bundle"
214-
RUBY="bundle exec ruby"
215-
RAKE="bundle exec rake"
216-
NPM="npm"
217-
NPX="npx"
218-
NODE="node"
219-
PYTHON="/opt/venv/bin/python3"
220-
PIP="/opt/venv/bin/pip"
221-
BASH="bash"
222-
GPP="g++"
223-
GDB="gdb"
224-
CLANG_FORMAT="clang-format"
225-
CLANG_TIDY="clang-tidy"
226-
MAKE="make"
227-
elif [ "${CONTAINER_TYPE}" == "docker" -o "${CONTAINER_TYPE}" == "podman" ]; then
228-
BUNDLE="${CONTAINER_BASE} bundle"
229-
RUBY="${CONTAINER_BASE} bundle exec ruby"
230-
RAKE="${CONTAINER_BASE} bundle exec rake"
231-
NPM="${CONTAINER_BASE} npm"
232-
NPX="${CONTAINER_BASE} npx"
233-
NODE="${CONTAINER_BASE} node"
234-
PYTHON="${CONTAINER_BASE} /opt/venv/bin/python3"
235-
PIP="${CONTAINER_BASE} /opt/venv/bin/pip"
236-
BASH="${CONTAINER_BASE} bash"
237-
GPP="${CONTAINER_BASE} g++"
238-
GDB="${CONTAINER_BASE} gdb"
239-
CLANG_FORMAT="${CONTAINER_BASE} clang-format"
240-
CLANG_TIDY="${CONTAINER_BASE} clang-tidy"
241-
MAKE="${CONTAINER_BASE} make"
242-
elif [ "${CONTAINER_TYPE}" == "singularity" ]; then
243-
BUNDLE="singularity run ${HOME_OPT} ${CONTAINER_PATH} bundle"
244-
RUBY="singularity run ${HOME_OPT} ${CONTAINER_PATH} bundle exec ruby"
245-
RAKE="singularity run ${HOME_OPT} ${CONTAINER_PATH} bundle exec rake"
246-
NPM="singularity run ${HOME_OPT} ${CONTAINER_PATH} npm"
247-
NPX="singularity run ${HOME_OPT} ${CONTAINER_PATH} npx"
248-
NODE="singularity run ${HOME_OPT} ${CONTAINER_PATH} node"
249-
PYTHON="singularity run ${HOME_OPT} ${CONTAINER_PATH} /opt/venv/bin/python3"
250-
PIP="singularity run ${HOME_OPT} ${CONTAINER_PATH} /opt/venv/bin/pip"
251-
BASH="singularity run ${HOME_OPT} ${CONTAINER_PATH} bash"
252-
GPP="singularity run ${HOME_OPT} ${CONTAINER_PATH} g++"
253-
GDB="singularity run ${HOME_OPT} ${CONTAINER_PATH} gdb"
254-
CLANG_FORMAT="singularity run ${HOME_OPT} ${CONTAINER_PATH} clang-format"
255-
CLANG_TIDY="singularity run ${HOME_OPT} ${CONTAINER_PATH} clang-tidy"
256-
MAKE="singularity run ${HOME_OPT} ${CONTAINER_PATH} make"
257-
else
258-
echo "Bad container type: ${CONTAINER_TYPE}" 1>&2
259-
exit 1
260-
fi
212+
# Set executables
213+
BUNDLE="${RUN} bundle"
214+
RUBY="${RUN} bundle exec ruby"
215+
RAKE="${RUN} bundle exec rake"
216+
NPM="${RUN} npm"
217+
NPX="${RUN} npx"
218+
NODE="${RUN} node"
219+
PYTHON="${RUN} /opt/venv/bin/python3"
220+
PIP="${RUN} /opt/venv/bin/pip"
221+
BASH="${RUN} bash"
222+
GPP="${RUN} g++"
223+
GDB="${RUN} gdb"
224+
CLANG_FORMAT="${RUN} clang-format"
225+
CLANG_TIDY="${RUN} clang-tidy"
226+
MAKE="${RUN} make"
261227

262228
git config --local commit.template ${ROOT}/.gitmessage
263229

0 commit comments

Comments
 (0)