Merge pull request #278 from augustobmoura/fix/add-link-cmds-npm-shim

Add auto reshim for npm link
This commit is contained in:
Augusto Moura 2021-12-24 00:55:29 -03:00 committed by GitHub
commit ed34355316
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,6 +22,7 @@ should_reshim() {
fi
local is_global= cmd= cmd_needs_reshim=
local additional_bare_cmds=()
for arg; do
case "$arg" in
@ -32,7 +33,11 @@ should_reshim() {
-*) ;; # Skip other options
*)
cmd="${cmd:-$arg}"
if ! [ "$cmd" ]; then
cmd="$arg"
else
additional_bare_cmds+=("$arg")
fi
;;
esac
done
@ -47,6 +52,20 @@ should_reshim() {
uninstall|un|unlink|remove|rm|r)
cmd_needs_reshim=true
;;
link|ln)
# Bare link installs a global package
if ! [ "${additional_bare_cmds[0]-}" ]; then
is_global=1
cmd_needs_reshim=true
fi
# Links to directories also install a global package
if [[ "${additional_bare_cmds[0]-}" =~ [./].* && -d "${additional_bare_cmds[0]-}" ]]; then
is_global=1
cmd_needs_reshim=true
fi
;;
esac
# Implicit return