fix(npx)!: detect new `npx` versions and fail gracefully (#10452)
BREAKING CHANGE: the `npx` plugin used a feature of `npx` to check for npm packages and run them if a command was not found. This feature was removed in v7.0.0 and was deemed insecure. The `npx` plugin is now officially deprecated and will be removed soon. Fixes #10452master
parent
fc40b53e64
commit
3741d1aa02
3 changed files with 14 additions and 32 deletions
@ -1,7 +1,12 @@ |
||||
# NPX Plugin |
||||
# https://www.npmjs.com/package/npx |
||||
# Maintainer: Pooya Parsa <pooya@pi0.ir> |
||||
if (( ! $+commands[npx] )); then |
||||
return |
||||
fi |
||||
|
||||
(( $+commands[npx] )) && { |
||||
source <(npx --shell-auto-fallback zsh) |
||||
} |
||||
if ! npx_fallback_script="$(npx --shell-auto-fallback zsh 2>/dev/null)"; then |
||||
print -u2 ${(%):-"%F{yellow}This \`npx\` version ($(npx --version)) is not supported.%f"} |
||||
else |
||||
source <(<<< "$npx_fallback_script") |
||||
fi |
||||
|
||||
print -u2 ${(%):-"%F{yellow}The \`npx\` plugin is deprecated and will be removed soon. %BPlease disable it%b.%f"} |
||||
unset npx_fallback_script |
||||
|
||||
@ -1,5 +1,5 @@ |
||||
print ${(%):-'%F{yellow}The `osx` plugin is deprecated and has been renamed to `macos`.'} |
||||
print ${(%):-'Please update your .zshrc to use the `%Bmacos%b` plugin instead.%f'} |
||||
print -u2 ${(%):-'%F{yellow}The `osx` plugin is deprecated and has been renamed to `macos`.'} |
||||
print -u2 ${(%):-'Please update your .zshrc to use the `%Bmacos%b` plugin instead.%f'} |
||||
|
||||
(( ${fpath[(Ie)$ZSH/plugins/macos]} )) || fpath=("$ZSH/plugins/macos" $fpath) |
||||
source "$ZSH/plugins/macos/macos.plugin.zsh" |
||||
|
||||
Loading…
Reference in new issue