Browse Source

Check if fnm is installed before shell setup (#937)

* Make install.sh tee instead of echoing twice

Also, fish bit was the only one that didn't print a newline to
$CONF_FILE, now they're all the same.

* Check if fnm is installed before shell setup

Change $CONF_FILE append strings to check whether $INSTALL_DIR exists
before doing any setup. This way whenever a user syncs their shell
config across machines, the machines without fnm installed won't throw
errors.

---------

Co-authored-by: Gal Schlezinger <gal@spitfire.co.il>
remotes/origin/use-bnz
Emilio Vesprini 9 months ago committed by GitHub
parent
commit
1b86087cf1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 54
      .ci/install.sh

54
.ci/install.sh

@ -168,29 +168,29 @@ setup_shell() { @@ -168,29 +168,29 @@ setup_shell() {
CONF_FILE=${ZDOTDIR:-$HOME}/.zshrc
ensure_containing_dir_exists "$CONF_FILE"
echo "Installing for Zsh. Appending the following to $CONF_FILE:"
echo ""
echo ' # fnm'
echo ' export PATH="'"$INSTALL_DIR"':$PATH"'
echo ' eval "`fnm env`"'
echo '' >>$CONF_FILE
echo '# fnm' >>$CONF_FILE
echo 'export PATH="'$INSTALL_DIR':$PATH"' >>$CONF_FILE
echo 'eval "`fnm env`"' >>$CONF_FILE
{
echo ''
echo '# fnm'
echo 'FNM_PATH="'"$INSTALL_DIR"'"'
echo 'if [ -d "$FNM_PATH" ]; then'
echo ' export PATH="'$INSTALL_DIR':$PATH"'
echo ' eval "`fnm env`"'
echo 'fi'
} | tee -a "$CONF_FILE"
elif [ "$CURRENT_SHELL" = "fish" ]; then
CONF_FILE=$HOME/.config/fish/conf.d/fnm.fish
ensure_containing_dir_exists "$CONF_FILE"
echo "Installing for Fish. Appending the following to $CONF_FILE:"
echo ""
echo ' # fnm'
echo ' set PATH "'"$INSTALL_DIR"'" $PATH'
echo ' fnm env | source'
echo '' >>$CONF_FILE
echo '# fnm' >>$CONF_FILE
echo 'set PATH "'"$INSTALL_DIR"'" $PATH' >>$CONF_FILE
echo 'fnm env | source' >>$CONF_FILE
{
echo ''
echo '# fnm'
echo 'set FNM_PATH "'"$INSTALL_DIR"'"'
echo 'if [ -d "$FNM_PATH" ]'
echo ' set PATH "$FNM_PATH" $PATH'
echo ' fnm env | source'
echo 'end'
} | tee -a "$CONF_FILE"
elif [ "$CURRENT_SHELL" = "bash" ]; then
if [ "$OS" = "Darwin" ]; then
@ -200,15 +200,15 @@ setup_shell() { @@ -200,15 +200,15 @@ setup_shell() {
fi
ensure_containing_dir_exists "$CONF_FILE"
echo "Installing for Bash. Appending the following to $CONF_FILE:"
echo ""
echo ' # fnm'
echo ' export PATH="'"$INSTALL_DIR"':$PATH"'
echo ' eval "`fnm env`"'
echo '' >>$CONF_FILE
echo '# fnm' >>$CONF_FILE
echo 'export PATH="'"$INSTALL_DIR"':$PATH"' >>$CONF_FILE
echo 'eval "`fnm env`"' >>$CONF_FILE
{
echo ''
echo '# fnm'
echo 'FNM_PATH="'"$INSTALL_DIR"'"'
echo 'if [ -d "$FNM_PATH" ]; then'
echo ' export PATH="$FNM_PATH:$PATH"'
echo ' eval "`fnm env`"'
echo 'fi'
} | tee -a "$CONF_FILE"
else
echo "Could not infer shell type. Please set up manually."

Loading…
Cancel
Save