Skip to content

Commit

Permalink
setup-node: support NODE_VERSIONS
Browse files Browse the repository at this point in the history
also only install npm packages if there are npm packages
  • Loading branch information
balupton committed Dec 4, 2023
1 parent 76333dc commit 0eadb80
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
19 changes: 18 additions & 1 deletion commands/setup-node
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function setup_node() (
# setup.bash provides:
local NPM_INSTALL=()
local NODE_INSTALL=() # deprecated, use NPM_INSTALL
local NODE_VERSIONS=()
load_dorothy_config 'setup.bash'

# deprecations
Expand Down Expand Up @@ -135,7 +136,23 @@ function setup_node() (
# =====================================
# Packages via npm

setup-util --installer=NODE -- "${NPM_INSTALL[@]}"
if test "${#NPM_INSTALL[@]}" -ne 0; then
echo-segment --h2='Node.js Packages'
setup-util --installer=NODE -- "${NPM_INSTALL[@]}"
echo-segment --g2='Node.js Packages'
fi

# =====================================
# Additional Node.js versions

local version
if test "${#NODE_VERSIONS[@]}" -ne 0; then
echo-segment --h2='Additional Node.js Versions'
for version in "${NODE_VERSIONS[@]}"; do
nvm-env -- nvm install "$version"
done
echo-segment --g2='Additional Node.js Versions'
fi

# =====================================
# Finish
Expand Down
1 change: 1 addition & 0 deletions config/setup.bash
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ HOMEBREW_FONTS=(
# Node.js
# Used by `setup-node`
# NPM_INSTALL=()
# NODE_VERSIONS=()

# Python
# Used by `setup-python`
Expand Down

0 comments on commit 0eadb80

Please sign in to comment.