mirror of
https://github.com/asdf-vm/asdf-nodejs.git
synced 2024-10-05 23:32:09 +08:00
Merge pull request #278 from augustobmoura/fix/add-link-cmds-npm-shim
Add auto reshim for npm link
This commit is contained in:
commit
ed34355316
21
shims/npm
21
shims/npm
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user