From 7b6df2d0c664e4bfcf4d037321516fabc82d5356 Mon Sep 17 00:00:00 2001 From: Andrew Thauer <6507159+andrewthauer@users.noreply.github.com> Date: Wed, 25 Apr 2018 22:32:34 -0400 Subject: [PATCH] Fix Issue #56: Can't install latest version of npm globally This works in tandom with a change in asdf core that will look for the exec-path command and use it appropriately when found to conditionally route the npm & npx commands to the correct executable path. --- bin/exec-path | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 bin/exec-path diff --git a/bin/exec-path b/bin/exec-path new file mode 100755 index 0000000..b244c51 --- /dev/null +++ b/bin/exec-path @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +install_path=$1 +cmd=$2 +executable_path=$3 + +if [[ "$cmd" == "npm" ]] || [[ "$cmd" == "npx" ]]; then + npm_bin_cmd=".npm/bin/$cmd" + + if [[ -f "$install_path/$npm_bin_cmd" ]]; then + executable_path="$npm_bin_cmd" + fi +fi + +echo "$executable_path"