PronounsPage/run-wrapper.sh
Valentyne Stigloher 4f7ccab2c6 (nuxt) use --env-file to read .env before nitro reads process.env, make dotenv.ts an import with side effects that only sets additional variables
care must be taken because everything initialized later will not be picked up by Nitro useRuntimeConfig() without passing an event
2025-03-14 22:18:09 +01:00

21 lines
640 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
exec node --env-file=.env .output/server/index.mjs -- "$(dirname "$0")" "$PORT"
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