diff --git a/plugins/npx/README.md b/plugins/npx/README.md index 41e4c135..4b2aba8f 100644 --- a/plugins/npx/README.md +++ b/plugins/npx/README.md @@ -1,27 +1,4 @@ -# NPX Plugin - -> npx(1) -- execute npm package binaries. ([more info](https://github.com/npm/npx)) - -This plugin automatically registers npx command-not-found handler if `npx` exists in your `$PATH`. - -To use it, add `npx` to the plugins array in your zshrc file: - -```zsh -plugins=(.... npx) -``` - -## Note - -The shell auto-fallback doesn't auto-install plain packages. In order to get it to install something, you need to add `@`: - -``` -➜ jasmine@latest # or just `jasmine@` -npx: installed 13 in 1.896s -Randomized with seed 54385 -Started -``` - -It does it this way so folks using the fallback don't accidentally try to install regular typoes. +# npx plugin ## Deprecation diff --git a/plugins/npx/npx.plugin.zsh b/plugins/npx/npx.plugin.zsh index 32bb6737..c1e2eca9 100644 --- a/plugins/npx/npx.plugin.zsh +++ b/plugins/npx/npx.plugin.zsh @@ -1,7 +1,12 @@ -# NPX Plugin -# https://www.npmjs.com/package/npx -# Maintainer: Pooya Parsa +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 diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index 9304e7f3..3b093598 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -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"