PronounsPage/run-wrapper.sh
Valentyne Stigloher c9103cdb45 (make)(pnpm)(ci) adjust script calls
as Nuxt builds a server bundle which does not read .env, run-wrapper.sh has a `start` subcommand to read from .env and start the bundle
2024-09-11 21:29:23 +02:00

25 lines
676 B
Bash
Executable File

#!/bin/bash
# wrapper for external contexts (cronjob, supervisor) which have no access to nvm to
# use the correct node version and execute node scripts
cd "$(dirname "$0")" || exit
nvm_bin=~/.nvm/versions/node/"$(<.nvmrc)"/bin
export PATH=$nvm_bin:$PATH
if [ "$1" = "start" ]; then
# load .env variables and start server
set -a
source .env
set +a
exec node .output/server/index.mjs
else
bin_file=./node_modules/.bin/"$1"
if [ -f "$bin_file" ]; then
# directly call bin files when possible to have no pnpm startup cost
exec "$bin_file" "${@:2}"
else
# call through pnpm in other cases
exec pnpm "$@"
fi
fi