From 1c06c0ab6149ced5881803fb999398517fe2d6cf Mon Sep 17 00:00:00 2001 From: cornfeedhobo Date: Wed, 8 Jul 2020 11:32:12 -0500 Subject: [PATCH] cleanup node plugin, and make it play nice with nodenv --- plugins/available/node.plugin.bash | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/available/node.plugin.bash b/plugins/available/node.plugin.bash index 429ca458..65df3da3 100644 --- a/plugins/available/node.plugin.bash +++ b/plugins/available/node.plugin.bash @@ -1,7 +1,13 @@ cite about-plugin about-plugin 'Node.js helper functions' +# Ensure local modules are preferred in PATH pathmunge "./node_modules/.bin" "after" -# Make sure the global npm prefix is on the path -[[ `which npm 2>/dev/null` ]] && pathmunge "$(npm config get prefix)/bin" "after" +# Check that we have npm +out=$(command -v npm 2>&1) || return + +# If not using nodenv, ensure global modules are in PATH +if [[ ! $out == *"nodenv/shims"* ]] ; then + pathmunge "$(npm config get prefix)/bin" "after" +fi