Skip to content

Commit

Permalink
Fix NVM path inside scripts (#40)
Browse files Browse the repository at this point in the history
### What was the problem?

This PR resolves LISK-944.

### How was it solved?

NVM path is manually loaded inside `installApplication.sh` script.
  • Loading branch information
matjazv authored and sameersubudhi committed Sep 10, 2024
1 parent c209daf commit a2970e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
7 changes: 5 additions & 2 deletions scripts/installApplication.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#!/bin/bash

source $HOME/.bashrc
# Load 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"

# Install application
# Change to application directory
app_dir_name=/home/ubuntu/lisk-across-relayer
cd $app_dir_name
echo "Current DIR: $PWD"

# Install application
nvm use
yarn install --frozen-lockfile
yarn build
18 changes: 3 additions & 15 deletions scripts/installDependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,11 @@ fi
# Function to install NVM
install_nvm() {
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash

# Add NVM load commands to .bashrc
if [ ! -f "$HOME/.bashrc" ];
then
touch $HOME/.bashrc
fi
if [ $(grep NVM_DIR "$HOME/.bashrc" | wc -l) -ge 2 ];
then
echo "NVM commands are already added to .bashrc"
else
echo "export NVM_DIR=\"\$HOME/.nvm\"" >> "$HOME/.bashrc"
echo "[ -s \"\$NVM_DIR/nvm.sh\" ] && \. \"\$NVM_DIR/nvm.sh\" # This loads nvm" >> "$HOME/.bashrc"
fi
}

install_node_version() {
# Check if NVM is installed
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
if [ -s "$NVM_DIR/nvm.sh" ];
then
echo "NVM is already installed."
Expand All @@ -41,8 +29,8 @@ install_node_version() {
install_nvm
fi

# Ensure NVM is now available in PATH
source "$HOME/.bashrc"
# Load NVM
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

echo "Installing Node version $node_version..."
nvm install $node_version
Expand Down

0 comments on commit a2970e9

Please sign in to comment.