jorgebucaran / nvm.fish

The Node.js version manager you'll adore, crafted just for Fish
https://git.io/nvm.fish
MIT License
2.06k stars 69 forks source link

nvm-exec script #211

Closed rob4226 closed 1 year ago

rob4226 commented 1 year ago

Hi, thank you for this great fish plugin!

nvm has an nvm-exec script which is useful when you're not in an interactive shell for things like systemd services like:

Environment=NODE_VERSION=16
ExecStart=/var/www/cryptpad/.nvm/nvm-exec node /var/www/cryptpad/server.js

Here's how nvm does it: https://github.com/nvm-sh/nvm/blob/master/nvm-exec

#!/usr/bin/env bash

DIR="$(command cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

unset NVM_CD_FLAGS

# shellcheck disable=SC1090,SC1091
\. "$DIR/nvm.sh" --no-use

if [ -n "$NODE_VERSION" ]; then
  nvm use "$NODE_VERSION" > /dev/null || exit 127
elif ! nvm use >/dev/null 2>&1; then
  echo "No NODE_VERSION provided; no .nvmrc file found" >&2
  exit 127
fi

exec "$@"

Does nvm.fish have something like this? Thank you.

jorgebucaran commented 1 year ago

Duplicated https://github.com/jorgebucaran/nvm.fish/issues/207

rob4226 commented 1 year ago

I believe the nvm exec command and the ./nvm-exec script are different things.

jorgebucaran commented 1 year ago

Oops, my bad! You're totally right. Yeah, we don't have that.