Skip to content

Commit 47d5c77

Browse files
committed
Wholesale cleanup of nodejs related components
- remove redundant cite - support Basher - add nenv plugin - uplift nodenv to follow newer pattern and standard - ensure node components play well with *env tools
1 parent 1882f50 commit 47d5c77

File tree

5 files changed

+33
-12
lines changed

5 files changed

+33
-12
lines changed

clean_files.txt

+1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ plugins/available/history.plugin.bash
9999
plugins/available/hub.plugin.bash
100100
plugins/available/jump.plugin.bash
101101
plugins/available/less-pretty-cat.plugin.bash
102+
plugins/available/nenv.plugin.bash
102103
plugins/available/node.plugin.bash
103104
plugins/available/nodenv.plugin.bash
104105
plugins/available/percol.plugin.bash
+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# shellcheck shell=bash
2-
cite "about-completion"
32
about-completion "npm (Node Package Manager) completion"
43

5-
if _command_exists npm; then
4+
# Test `npm version` because *env tools create shim scripts that will be found in PATH
5+
# but do not always resolve to a working install.
6+
if _command_exists npm && npm --version &> /dev/null; then
67
eval "$(npm completion)"
78
fi

plugins/available/nenv.plugin.bash

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# shellcheck shell=bash
2+
about-plugin 'load nenv, if you are using it'
3+
4+
# Load after basher
5+
# BASH_IT_LOAD_PRIORITY: 260
6+
7+
export NENV_ROOT="${NENV_ROOT:-${HOME?}/.nenv}"
8+
9+
if [[ -d "${NENV_ROOT?}/bin" ]]; then
10+
pathmunge "${NENV_ROOT?}/bin"
11+
fi
12+
13+
if _command_exists nenv; then
14+
eval "$(nenv init - bash)"
15+
fi

plugins/available/node.plugin.bash

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
# shellcheck shell=bash
2-
cite about-plugin
32
about-plugin 'Node.js helper functions'
43

5-
# Check that we have npm
6-
_command_exists npm || return
4+
# Load after *env plugins
5+
# BASH_IT_LOAD_PRIORITY: 270
76

87
# Ensure local modules are preferred in PATH
9-
pathmunge "./node_modules/.bin" "after"
8+
pathmunge './node_modules/.bin' 'after'
109

11-
# If not using nodenv, ensure global modules are in PATH
12-
if [[ ! "$(type -p npm)" == *"nodenv/shims"* ]]; then
13-
pathmunge "$(npm config get prefix)/bin" "after"
10+
# If not using an *env tool, ensure global modules are in PATH
11+
if [[ ! "$(type -p npm)" == *'/shims/npm' ]]; then
12+
pathmunge "$(npm config get prefix)/bin" 'after'
1413
fi

plugins/available/nodenv.plugin.bash

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
# shellcheck shell=bash
2-
cite about-plugin
32
about-plugin 'load nodenv, if you are using it'
43

5-
export NODENV_ROOT="$HOME/.nodenv"
6-
pathmunge "$NODENV_ROOT/bin"
4+
# Load after basher
5+
# BASH_IT_LOAD_PRIORITY: 260
6+
7+
export NODENV_ROOT="${NODENV_ROOT:-${HOME?}/.nodenv}"
8+
9+
if [[ -d "${NODENV_ROOT?}/bin" ]]; then
10+
pathmunge "${NODENV_ROOT?}/bin"
11+
fi
712

813
if _command_exists nodenv; then
914
eval "$(nodenv init - bash)"

0 commit comments

Comments
 (0)