Drop automation of all-the-package-names install for npm completions

Selectively reverts 156d4fb9b9.

`all-the-package-names` is still used to generate completions for `npm`
if it is installed, but it is not manually installed nor updated. It is
now the user's responsibility to do both, and it must be installed
globally.
This commit is contained in:
Mahmoud Al-Qudsi 2018-04-19 08:15:50 -05:00
parent 54959a8248
commit 503427255e
2 changed files with 9 additions and 23 deletions

View file

@ -69,8 +69,11 @@ This section is for changes merged to the `major` branch that are not also merge
- `brew`
- `diskutil`
- `git` (#4395, #4396, #4592)
- `npm`<sup></sup>
- `ssh` (#4344)
- `yarn`
- `yarn`<sup></sup>
_† for autocompletion of available packages for installation via `npm` or `yarn`, make sure `all-the-package-names` is installed (typically: `sudo npm install -g all-the-package-names`)._
--

View file

@ -4,31 +4,14 @@
# see also Fish's large set of completions for examples:
# https://github.com/fish-shell/fish-shell/tree/master/share/completions
set -g __fish_atpm_cache $HOME/.cache/fish/npm_completions
function __install_atpm
if not test -d $__fish_atpm_cache
mkdir -p $__fish_atpm_cache
fish -c "cd $HOME/.cache/fish/npm_completions; npm init -y >/dev/null; npm install all-the-package-names >/dev/null; touch .last_update" >/dev/null 2>/dev/null
end
end
function __update_atpm
if test \"(find $__fish_atpm_cache/ -name .last_update -mtime +1 -print)\"
# all-the-package-names is out of date
fish -c "cd $__fish_atpm_cache; npm update; touch .last_update" >/dev/null 2>/dev/null
end
end
# If all-the-package-names is installed, it will be used to generate npm completions.
# Install globally with `sudo npm install -g all-the-package-names`. Keep it up to date.
function __npm_list_packages
if not test -x $__fish_atpm_cache/node_modules/.bin/all-the-package-names
if not __install_atpm >/dev/null
return
end
if not type -q all-the-package-names
return
end
__update_atpm >/dev/null
eval $__fish_atpm_cache/node_modules/.bin/all-the-package-names
all-the-package-names
end
# Entire list of packages is too long to be used in a `complete` subcommand