From 12ce1bfd81e98c3683f68fce9d18d094a42d2f46 Mon Sep 17 00:00:00 2001 From: Augusto Moura Date: Mon, 19 Jul 2021 15:44:21 -0300 Subject: [PATCH] fix: adds support for pipe in paths --- shims/npm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/shims/npm b/shims/npm index 1520938..5c6731e 100755 --- a/shims/npm +++ b/shims/npm @@ -9,9 +9,13 @@ set -o pipefail this_dir="$(dirname "${BASH_SOURCE[0]}")" plugin_name="$(basename "$(dirname "$this_dir")")" -# Remove current script from path and search the next npm script available -# It works because asdf-core adds the every binarie path candidate in path before calling this script -filtered_path="$(sed "s|$this_dir||g; s|::|:|g" <<< "$PATH")" +quote_path() { + sed 's/\\/\\\\/g; s/\//\\\//g' <<< "$1" +} + +# Remove current script from path and search the next npm executable +# It works because asdf-core adds every binary path candidate to PATH before calling this script +filtered_path="$(sed "s/$(quote_path "$this_dir")//g; s/::/:/g" <<< "$PATH")" npm="$(PATH="$filtered_path" command -v npm)" should_reshim() {