Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions bin/bootstrap-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,16 @@ DOCKER_COMPOSE_FILE_OPTIONS="-f docker-compose.yml"
if [ "$DOCKER_ENV" == "localwpdev" ]; then
DOCKER_COMPOSE_FILE_OPTIONS="${DOCKER_COMPOSE_FILE_OPTIONS} -f docker-compose-localdev.yml"
fi

# Check for skip-nvm-setup flag. Used in install-node-nvm.sh
while getopts ":-:" opt; do
case "${opt}" in
-)
case "${OPTARG}" in
skip-nvm-setup)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open to suggestions on renaming this flag name.

SKIP_NVM_SETUP=true
;;
esac;;
esac
done

88 changes: 45 additions & 43 deletions bin/install-node-nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,62 +7,64 @@ set -e
# Include useful functions
. "$(dirname "$0")/includes.sh"

# Load NVM
if [ -n "$NVM_DIR" ]; then
# The --no-use option ensures loading NVM doesn't switch the current version.
if [ -f "$NVM_DIR/nvm.sh" ]; then
. "$NVM_DIR/nvm.sh" --no-use
elif command_exists "brew" && [ -f "$(brew --prefix nvm)/nvm.sh" ]; then
# use homebrew if that's how nvm was installed
. "$(brew --prefix nvm)/nvm.sh" --no-use
if [ "$SKIP_NVM_SETUP" != "true" ]; then
# Load NVM
if [ -n "$NVM_DIR" ]; then
# The --no-use option ensures loading NVM doesn't switch the current version.
if [ -f "$NVM_DIR/nvm.sh" ]; then
. "$NVM_DIR/nvm.sh" --no-use
elif command_exists "brew" && [ -f "$(brew --prefix nvm)/nvm.sh" ]; then
# use homebrew if that's how nvm was installed
. "$(brew --prefix nvm)/nvm.sh" --no-use
fi
fi
fi

# Change to the expected directory
cd "$(dirname "$0")/.."
# Change to the expected directory
cd "$(dirname "$0")/.."

# Check if nvm is installed
if [ "$TRAVIS" != "true" ] && ! command_exists "nvm"; then
if ask "$(error_message "NVM isn't installed, would you like to download and install it automatically?")" Y; then
# The .bash_profile file needs to exist for NVM to install
if [ ! -e ~/.bash_profile ]; then
touch ~/.bash_profile
fi

echo -en $(status_message "Installing NVM..." )
download "https://raw.githubusercontent.com/creationix/nvm/$NVM_VERSION/install.sh" | bash >/dev/null 2>&1
echo ' done!'

# Check if nvm is installed
if [ "$TRAVIS" != "true" ] && ! command_exists "nvm"; then
if ask "$(error_message "NVM isn't installed, would you like to download and install it automatically?")" Y; then
# The .bash_profile file needs to exist for NVM to install
if [ ! -e ~/.bash_profile ]; then
touch ~/.bash_profile
echo -e $(warning_message "NVM was updated, please run this command to reload it:" )
echo -e $(warning_message "$(action_format ". \$HOME/.nvm/nvm.sh")" )
echo -e $(warning_message "After that, re-run the setup script to continue." )
else
echo -e $(error_message "")
echo -e $(error_message "Please install NVM manually, then re-run the setup script to continue.")
echo -e $(error_message "NVM installation instructions can be found here: $(action_format "https://github.com/creationix/nvm")")
fi

echo -en $(status_message "Installing NVM..." )
exit 1
fi

# Check if the current nvm version is up to date.
if [ "$TRAVIS" != "true" ] && [ $NVM_VERSION != "v$(nvm --version)" ]; then
echo -en $(status_message "Updating NVM..." )
download "https://raw.githubusercontent.com/creationix/nvm/$NVM_VERSION/install.sh" | bash >/dev/null 2>&1
echo ' done!'

echo -e $(warning_message "NVM was updated, please run this command to reload it:" )
echo -e $(warning_message "$(action_format ". \$HOME/.nvm/nvm.sh")" )
echo -e $(warning_message "After that, re-run the setup script to continue." )
else
echo -e $(error_message "")
echo -e $(error_message "Please install NVM manually, then re-run the setup script to continue.")
echo -e $(error_message "NVM installation instructions can be found here: $(action_format "https://github.com/creationix/nvm")")
exit 1
fi

exit 1
fi

# Check if the current nvm version is up to date.
if [ "$TRAVIS" != "true" ] && [ $NVM_VERSION != "v$(nvm --version)" ]; then
echo -en $(status_message "Updating NVM..." )
download "https://raw.githubusercontent.com/creationix/nvm/$NVM_VERSION/install.sh" | bash >/dev/null 2>&1
echo ' done!'

echo -e $(warning_message "NVM was updated, please run this command to reload it:" )
echo -e $(warning_message "$(action_format ". \$HOME/.nvm/nvm.sh")" )
echo -e $(warning_message "After that, re-run the setup script to continue." )
exit 1
fi

# Check if the current node version is up to date.
if [ "$TRAVIS" != "true" ] && [ "$(nvm current)" != "$(nvm version-remote --lts)" ]; then
echo -e $(warning_message "Node version does not match the latest long term support version. Please run this command to install and use it:" )
echo -e $(warning_message "$(action_format "nvm install")" )
echo -e $(warning_message "After that, re-run the setup script to continue." )
exit 1
# Check if the current node version is up to date.
if [ "$TRAVIS" != "true" ] && [ "$(nvm current)" != "$(nvm version-remote --lts)" ]; then
echo -e $(warning_message "Node version does not match the latest long term support version. Please run this command to install and use it:" )
echo -e $(warning_message "$(action_format "nvm install")" )
echo -e $(warning_message "After that, re-run the setup script to continue." )
exit 1
fi
fi

# Install/update packages
Expand Down
2 changes: 2 additions & 0 deletions docs/contributors/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ nvm install
nvm use
```

**If you want to skip the setup and installation for NVM**, you can pass `--skip-nvm-setup` flag to the script, `./bin/setup-local-env.sh --skip-nvm-setup`. This can be needed, if you already have Node installed manually or via any other version manager like [nodenv](https://github.com/nodenv/nodenv/) or [asdf](https://github.com/asdf-vm/asdf-nodejs).

You also should have the latest release of [npm installed][npm]. npm is a separate project from Node.js and is updated frequently. If you've just installed Node.js which includes a version of npm within the installation you most likely will need also to update your npm installation. To update npm, type this into your terminal: `npm install npm@latest -g`

To test the plugin, or to contribute to it, you can clone this repository and build the plugin files using Node. How you do that depends on whether you're developing locally or uploading the plugin to a remote host.
Expand Down