Skip to content

Commit

Permalink
🐛 add default package configuration in nvm installation script
Browse files Browse the repository at this point in the history
  • Loading branch information
wingy3181 committed Nov 29, 2023
1 parent fec8257 commit beb06b6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
6 changes: 0 additions & 6 deletions src/nvm/nvm/default-packages

This file was deleted.

2 changes: 0 additions & 2 deletions src/os/create_symbolic_links.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ create_symlinks() {

"npm/npmrc"

"nvm/nvm/default-packages"

"vim/vim"
"vim/vimrc"

Expand Down
25 changes: 24 additions & 1 deletion src/os/installs/nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,28 @@ install_nvm() {

}

configure_nvm_default_packages() {

# Configure default global packages from file when
# installing a new node version
#
# https://github.com/nvm-sh/nvm#default-global-packages-from-file-while-installing
declare -r DEFAULT_PACKAGES_CONFIG="
commitizen
cz-customizable
mrm
@wingy3181/mrm-preset-wingy3181
@lobehub/commit-cli
prettier
"

# '>>' : file to append to
execute_without_spinner \
"printf '%s' '$DEFAULT_PACKAGES_CONFIG' >> $HOME/.nvm/default-packages" \
"Update $HOME/.nvm/default-packages"

}

update_nvm() {

execute \
Expand All @@ -73,8 +95,9 @@ main() {

print_in_purple "\n nvm\n\n"

if [ ! -d "$NVM_DIRECTORY" ] || [ -d "$NVM_DIRECTORY" ] && [ "$(find "$NVM_DIRECTORY" -maxdepth 1 ! -type d | wc -l)" -eq 1 ]; then # -d : True if file exists and is a directory.
if [ ! -d "$NVM_DIRECTORY" ]; then # -d : True if file exists and is a directory.
install_nvm
configure_nvm_default_packages
else
# Ensure the latest version of `nvm` is used
update_nvm
Expand Down

0 comments on commit beb06b6

Please sign in to comment.