Skip to content

Commit

Permalink
Clean up installDependencies script
Browse files Browse the repository at this point in the history
  • Loading branch information
matjazv committed Aug 14, 2024
1 parent 7f9c7f0 commit 3d022a4
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions scripts/installDependencies.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Install nodejs dependencies
apt update
echo "Current DIR: $PWD"
# Script to install Node.js using NVM on Ubuntu

Expand All @@ -9,24 +8,23 @@ node_version=$(cat .nvmrc | tr -d "\n")
# Function to install NVM
install_nvm() {
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
}

# nvm command is a shell function declared in ~/.nvm/nvm.sh
nvm_path=~/.nvm/nvm.sh

install_node_version() {
# Check if NVM is installed
if [ -s "$nvm_path" ];
export NVM_DIR="$HOME/.nvm"

if [ -s "$NVM_DIR/nvm.sh" ];
then
echo "NVM is already installed."
source $nvm_path
else
echo "Installing NVM..."
install_nvm
source $nvm_path
fi

# Setting up environment for NVM
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

echo "Installing Node version $node_version..."
nvm install $node_version
Expand All @@ -37,8 +35,6 @@ install_node_version
echo "Node.js version $node_version has been installed."

# Install yarn
npm install --global yarn
echo "***Installed yarn***"
npm install -g yarn
# Install pm2
npm install --global pm2@latest
echo "***Installed pm2***"
npm install --global pm2@latest

0 comments on commit 3d022a4

Please sign in to comment.