From 9caa7af7b8b8360e3a79995817016b7d75cd1510 Mon Sep 17 00:00:00 2001 From: Bruno Pinto Date: Sun, 10 Mar 2013 14:23:01 -0300 Subject: [PATCH] support for local npm packages when loading shell --- plugins/node/node.load | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/plugins/node/node.load b/plugins/node/node.load index 77ee7ac..c81816e 100644 --- a/plugins/node/node.load +++ b/plugins/node/node.load @@ -1,10 +1,5 @@ -if test -d /usr/local/share/npm/bin - set PATH /usr/local/share/npm/bin $PATH -end - -function __check_node_project --on-variable PWD --description 'Setup local npm binaries on directory change' - status --is-command-substitution; and return - +### Functions +function __remove_local_npm_binaries_from_path set -l count 1 for path in $PATH @@ -14,10 +9,25 @@ function __check_node_project --on-variable PWD --description 'Setup local npm b set count (math $count + 1) end end +end +function __add_local_npm_binaries_to_path for path in $PWD/node_modules/*/bin set PATH $path $PATH end - - set -e count +end + + +### Main program +if test -d /usr/local/share/npm/bin + set PATH /usr/local/share/npm/bin $PATH +end + +__add_local_npm_binaries_to_path + +function __check_node_project --on-variable PWD --description 'Setup local npm binaries on directory change' + status --is-command-substitution; and return + + __remove_local_npm_binaries_from_path + __add_local_npm_binaries_to_path end