clean up nodenv and node plugins
parent
176abe43b5
commit
72f326ac78
|
|
@ -0,0 +1,6 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# Bash completion support for nodenv
|
||||||
|
|
||||||
|
if _command_exists nodenv && [[ -r "$(dirname $(readlink -f $(which nodenv)))/../completions/nodenv.bash" ]] ; then
|
||||||
|
source "$(dirname $(readlink -f $(which nodenv)))/../completions/nodenv.bash"
|
||||||
|
fi
|
||||||
|
|
@ -1,13 +1,17 @@
|
||||||
cite about-plugin
|
cite about-plugin
|
||||||
about-plugin 'Node.js helper functions'
|
about-plugin 'Node.js helper functions'
|
||||||
|
|
||||||
# Ensure local modules are preferred in PATH
|
# Load after nodenv
|
||||||
pathmunge "./node_modules/.bin" "after"
|
# BASH_IT_LOAD_PRIORITY: 285
|
||||||
|
|
||||||
# Check that we have npm
|
# Check node version to ensure nodenv can find node
|
||||||
out=$(command -v npm 2>&1) || return
|
{ _command_exists node && node --version &>/dev/null ; } || return 0
|
||||||
|
|
||||||
# If not using nodenv, ensure global modules are in PATH
|
# Check npm version to ensure nodenv can find npm
|
||||||
if [[ ! $out == *"nodenv/shims"* ]] ; then
|
{ _command_exists npm && npm --version &>/dev/null ; } || return 0
|
||||||
pathmunge "$(npm config get prefix)/bin" "after"
|
|
||||||
fi
|
# Ensure global modules are in PATH
|
||||||
|
pathmunge "$(npm config get prefix)/bin"
|
||||||
|
|
||||||
|
# Ensure local modules are in PATH
|
||||||
|
pathmunge './node_modules/.bin'
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,24 @@
|
||||||
cite about-plugin
|
cite about-plugin
|
||||||
about-plugin 'load nodenv, if you are using it'
|
about-plugin 'load nodenv, if you are using it'
|
||||||
|
|
||||||
export NODENV_ROOT="$HOME/.nodenv"
|
# Load after basher
|
||||||
pathmunge "$NODENV_ROOT/bin"
|
# BASH_IT_LOAD_PRIORITY: 275
|
||||||
|
|
||||||
[[ `which nodenv` ]] && eval "$(nodenv init - bash)"
|
# Don't modify the environment if we can't find the tool:
|
||||||
|
# - Check if in $PATH already
|
||||||
|
# - Check if installed manually to $NODENV_ROOT
|
||||||
|
# - Check if installed manually to $HOME
|
||||||
|
_command_exists nodenv ||
|
||||||
|
[[ -n "$NODENV_ROOT" && -x "$RBENV_ROOT/bin/nodenv" ]] ||
|
||||||
|
[[ -x "$HOME/.nodenv/bin/nodenv" ]] ||
|
||||||
|
return 0
|
||||||
|
|
||||||
|
# Set NODENV_ROOT, if not already set
|
||||||
|
export NODENV_ROOT="${NODENV_ROOT:-$(nodenv root)}"
|
||||||
|
|
||||||
|
# Add NODENV_ROOT/bin to PATH, if that's where it's installed
|
||||||
|
if ! _command_exists nodenv && [[ -x "$NODENV_ROOT/bin/nodenv" ]] ; then
|
||||||
|
pathmunge "$NODENV_ROOT/bin"
|
||||||
|
fi
|
||||||
|
|
||||||
|
eval "$(nodenv init - bash)"
|
||||||
|
|
|
||||||
|
|
@ -134,21 +134,21 @@ function local_setup {
|
||||||
|
|
||||||
@test "helpers: enable the node plugin" {
|
@test "helpers: enable the node plugin" {
|
||||||
run _enable-plugin "node"
|
run _enable-plugin "node"
|
||||||
assert_line -n 0 'node enabled with priority 250.'
|
assert_line -n 0 'node enabled with priority 285.'
|
||||||
assert_link_exist "$BASH_IT/enabled/250---node.plugin.bash" "../plugins/available/node.plugin.bash"
|
assert_link_exist "$BASH_IT/enabled/285---node.plugin.bash" "../plugins/available/node.plugin.bash"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "helpers: enable the node plugin through the bash-it function" {
|
@test "helpers: enable the node plugin through the bash-it function" {
|
||||||
run bash-it enable plugin "node"
|
run bash-it enable plugin "node"
|
||||||
assert_line -n 0 'node enabled with priority 250.'
|
assert_line -n 0 'node enabled with priority 285.'
|
||||||
assert_link_exist "$BASH_IT/enabled/250---node.plugin.bash"
|
assert_link_exist "$BASH_IT/enabled/285---node.plugin.bash"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "helpers: enable the node and nvm plugins through the bash-it function" {
|
@test "helpers: enable the node and nvm plugins through the bash-it function" {
|
||||||
run bash-it enable plugin "node" "nvm"
|
run bash-it enable plugin "node" "nvm"
|
||||||
assert_line -n 0 'node enabled with priority 250.'
|
assert_line -n 0 'node enabled with priority 285.'
|
||||||
assert_line -n 1 'nvm enabled with priority 225.'
|
assert_line -n 1 'nvm enabled with priority 225.'
|
||||||
assert_link_exist "$BASH_IT/enabled/250---node.plugin.bash"
|
assert_link_exist "$BASH_IT/enabled/285---node.plugin.bash"
|
||||||
assert_link_exist "$BASH_IT/enabled/225---nvm.plugin.bash"
|
assert_link_exist "$BASH_IT/enabled/225---nvm.plugin.bash"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -299,7 +299,7 @@ function local_setup {
|
||||||
assert_line -n 2 'todo.txt-cli enabled with priority 150.'
|
assert_line -n 2 'todo.txt-cli enabled with priority 150.'
|
||||||
|
|
||||||
assert_link_exist "$BASH_IT/enabled/225---nvm.plugin.bash"
|
assert_link_exist "$BASH_IT/enabled/225---nvm.plugin.bash"
|
||||||
assert_link_exist "$BASH_IT/enabled/250---node.plugin.bash"
|
assert_link_exist "$BASH_IT/enabled/285---node.plugin.bash"
|
||||||
assert_link_exist "$BASH_IT/enabled/250---ssh.plugin.bash"
|
assert_link_exist "$BASH_IT/enabled/250---ssh.plugin.bash"
|
||||||
assert_link_exist "$BASH_IT/enabled/150---todo.txt-cli.aliases.bash"
|
assert_link_exist "$BASH_IT/enabled/150---todo.txt-cli.aliases.bash"
|
||||||
assert [ ! -L "$BASH_IT/plugins/enabled/node.plugin.bash" ]
|
assert [ ! -L "$BASH_IT/plugins/enabled/node.plugin.bash" ]
|
||||||
|
|
@ -311,8 +311,8 @@ function local_setup {
|
||||||
ln -s $BASH_IT/plugins/available/nvm.plugin.bash $BASH_IT/plugins/enabled/225---nvm.plugin.bash
|
ln -s $BASH_IT/plugins/available/nvm.plugin.bash $BASH_IT/plugins/enabled/225---nvm.plugin.bash
|
||||||
assert_link_exist "$BASH_IT/plugins/enabled/225---nvm.plugin.bash"
|
assert_link_exist "$BASH_IT/plugins/enabled/225---nvm.plugin.bash"
|
||||||
|
|
||||||
ln -s $BASH_IT/plugins/available/node.plugin.bash $BASH_IT/plugins/enabled/250---node.plugin.bash
|
ln -s $BASH_IT/plugins/available/node.plugin.bash $BASH_IT/plugins/enabled/285---node.plugin.bash
|
||||||
assert_link_exist "$BASH_IT/plugins/enabled/250---node.plugin.bash"
|
assert_link_exist "$BASH_IT/plugins/enabled/285---node.plugin.bash"
|
||||||
|
|
||||||
ln -s $BASH_IT/aliases/available/todo.txt-cli.aliases.bash $BASH_IT/aliases/enabled/250---todo.txt-cli.aliases.bash
|
ln -s $BASH_IT/aliases/available/todo.txt-cli.aliases.bash $BASH_IT/aliases/enabled/250---todo.txt-cli.aliases.bash
|
||||||
assert_link_exist "$BASH_IT/aliases/enabled/250---todo.txt-cli.aliases.bash"
|
assert_link_exist "$BASH_IT/aliases/enabled/250---todo.txt-cli.aliases.bash"
|
||||||
|
|
@ -322,10 +322,10 @@ function local_setup {
|
||||||
|
|
||||||
run _bash-it-migrate
|
run _bash-it-migrate
|
||||||
assert_link_exist "$BASH_IT/enabled/225---nvm.plugin.bash"
|
assert_link_exist "$BASH_IT/enabled/225---nvm.plugin.bash"
|
||||||
assert_link_exist "$BASH_IT/enabled/250---node.plugin.bash"
|
assert_link_exist "$BASH_IT/enabled/285---node.plugin.bash"
|
||||||
assert_link_exist "$BASH_IT/enabled/250---ssh.plugin.bash"
|
assert_link_exist "$BASH_IT/enabled/250---ssh.plugin.bash"
|
||||||
assert_link_exist "$BASH_IT/enabled/150---todo.txt-cli.aliases.bash"
|
assert_link_exist "$BASH_IT/enabled/150---todo.txt-cli.aliases.bash"
|
||||||
assert [ ! -L "$BASH_IT/plugins/enabled/225----node.plugin.bash" ]
|
assert [ ! -L "$BASH_IT/plugins/enabled/250----node.plugin.bash" ]
|
||||||
assert [ ! -L "$BASH_IT/plugins/enabled/250----nvm.plugin.bash" ]
|
assert [ ! -L "$BASH_IT/plugins/enabled/250----nvm.plugin.bash" ]
|
||||||
assert [ ! -L "$BASH_IT/aliases/enabled/250----todo.txt-cli.aliases.bash" ]
|
assert [ ! -L "$BASH_IT/aliases/enabled/250----todo.txt-cli.aliases.bash" ]
|
||||||
}
|
}
|
||||||
|
|
@ -424,22 +424,22 @@ function __migrate_all_components() {
|
||||||
assert_line -n 1 'nvm disabled.'
|
assert_line -n 1 'nvm disabled.'
|
||||||
assert_line -n 2 'nvm enabled with priority 225.'
|
assert_line -n 2 'nvm enabled with priority 225.'
|
||||||
assert_line -n 3 'If any migration errors were reported, please try the following: reload && bash-it migrate'
|
assert_line -n 3 'If any migration errors were reported, please try the following: reload && bash-it migrate'
|
||||||
assert_line -n 4 'node enabled with priority 250.'
|
assert_line -n 4 'node enabled with priority 285.'
|
||||||
assert [ ! -L "$BASH_IT/plugins/enabled/nvm.plugin.bash" ]
|
assert [ ! -L "$BASH_IT/plugins/enabled/nvm.plugin.bash" ]
|
||||||
assert_link_exist "$BASH_IT/enabled/225---nvm.plugin.bash"
|
assert_link_exist "$BASH_IT/enabled/225---nvm.plugin.bash"
|
||||||
assert_link_exist "$BASH_IT/enabled/250---node.plugin.bash"
|
assert_link_exist "$BASH_IT/enabled/285---node.plugin.bash"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "helpers: verify that existing components are automatically migrated when something is disabled" {
|
@test "helpers: verify that existing components are automatically migrated when something is disabled" {
|
||||||
ln -s $BASH_IT/plugins/available/nvm.plugin.bash $BASH_IT/plugins/enabled/nvm.plugin.bash
|
ln -s $BASH_IT/plugins/available/nvm.plugin.bash $BASH_IT/plugins/enabled/nvm.plugin.bash
|
||||||
assert_link_exist "$BASH_IT/plugins/enabled/nvm.plugin.bash"
|
assert_link_exist "$BASH_IT/plugins/enabled/nvm.plugin.bash"
|
||||||
ln -s $BASH_IT/plugins/available/node.plugin.bash $BASH_IT/plugins/enabled/250---node.plugin.bash
|
ln -s $BASH_IT/plugins/available/node.plugin.bash $BASH_IT/plugins/enabled/285---node.plugin.bash
|
||||||
assert_link_exist "$BASH_IT/plugins/enabled/250---node.plugin.bash"
|
assert_link_exist "$BASH_IT/plugins/enabled/285---node.plugin.bash"
|
||||||
|
|
||||||
run bash-it disable plugin "node"
|
run bash-it disable plugin "node"
|
||||||
assert_line -n 0 'Migrating plugin node.'
|
assert_line -n 0 'Migrating plugin node.'
|
||||||
assert_line -n 1 'node disabled.'
|
assert_line -n 1 'node disabled.'
|
||||||
assert_line -n 2 'node enabled with priority 250.'
|
assert_line -n 2 'node enabled with priority 285.'
|
||||||
assert_line -n 3 'Migrating plugin nvm.'
|
assert_line -n 3 'Migrating plugin nvm.'
|
||||||
assert_line -n 4 'nvm disabled.'
|
assert_line -n 4 'nvm disabled.'
|
||||||
assert_line -n 5 'nvm enabled with priority 225.'
|
assert_line -n 5 'nvm enabled with priority 225.'
|
||||||
|
|
@ -447,8 +447,8 @@ function __migrate_all_components() {
|
||||||
assert_line -n 7 'node disabled.'
|
assert_line -n 7 'node disabled.'
|
||||||
assert [ ! -L "$BASH_IT/plugins/enabled/nvm.plugin.bash" ]
|
assert [ ! -L "$BASH_IT/plugins/enabled/nvm.plugin.bash" ]
|
||||||
assert_link_exist "$BASH_IT/enabled/225---nvm.plugin.bash"
|
assert_link_exist "$BASH_IT/enabled/225---nvm.plugin.bash"
|
||||||
assert [ ! -L "$BASH_IT/plugins/enabled/250---node.plugin.bash" ]
|
assert [ ! -L "$BASH_IT/plugins/enabled/285---node.plugin.bash" ]
|
||||||
assert [ ! -L "$BASH_IT/enabled/250---node.plugin.bash" ]
|
assert [ ! -L "$BASH_IT/enabled/285---node.plugin.bash" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "helpers: enable all plugins" {
|
@test "helpers: enable all plugins" {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue