diff options
| author | Markus Heiser <markus.heiser@darmarIT.de> | 2021-11-21 23:49:05 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-21 23:49:05 +0100 |
| commit | deca799e9feebc411339f11d9050f4250c40db13 (patch) | |
| tree | 4be4bf5457d25b45b289481e330d2642a50a51ac /utils | |
| parent | 02cccdf876f2e0b07ef488e6033a858113dc3f1c (diff) | |
| parent | 5242a841a5dd2179d1ed620a67594932eb129422 (diff) | |
Merge pull request #529 from return42/nvm-improve
Various improvements of the NVM environment
Diffstat (limited to 'utils')
| -rwxr-xr-x | utils/lib_nvm.sh | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/utils/lib_nvm.sh b/utils/lib_nvm.sh index d35abef2a..267ba8a4a 100755 --- a/utils/lib_nvm.sh +++ b/utils/lib_nvm.sh @@ -94,6 +94,7 @@ nvm.: use nvm (without dot) to execute nvm commands directly clean : remove NVM installation status : prompt some status informations about nvm & node nodejs : install Node.js latest LTS + cmd ... : run command ... in NVM environment bash : start bash interpreter with NVM environment sourced EOF } @@ -115,6 +116,8 @@ nvm.install() { NVM_VERSION_TAG="$(git describe --abbrev=0 --tags --match "v[0-9]*" "${NVM_VERSION_TAG}")" info_msg "checkout ${NVM_VERSION_TAG}" git checkout "${NVM_VERSION_TAG}" 2>&1 | prefix_stdout " ${_Yellow}||${_creset} " + popd &> /dev/null + cp "${REPO_ROOT}/.nvm_packages" "${NVM_DIR}/default-packages" nvm.env } @@ -133,7 +136,7 @@ nvm.clean() { fi } -nvm.status(){ +nvm.status() { if command -v node >/dev/null; then info_msg "Node.js is installed at $(command -v node)" info_msg "Node.js is version $(node --version)" @@ -153,12 +156,12 @@ nvm.status(){ info_msg "NVM is installed at ${NVM_DIR}" else warn_msg "NVM is not installed" - info_msg "to install NVM and Node.js (LTS) use: ${main_cmd} nvm install --lts" + info_msg "to install NVM and Node.js (LTS) use: ${main_cmd} nvm.nodejs" fi } -nvm.nodejs(){ - nvm install --lts +nvm.nodejs() { + nvm install nvm.status } @@ -167,6 +170,11 @@ nvm.bash() { bash --init-file <(cat "${NVM_DIR}/nvm.sh" "${NVM_DIR}/bash_completion") } +nvm.cmd() { + nvm.ensure + "$@" +} + nvm.ensure() { if ! nvm.is_installed; then nvm.install |