From 503427255e6a4abade0b3490f25bd0b323d2429a Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Thu, 19 Apr 2018 08:15:50 -0500 Subject: [PATCH] Drop automation of `all-the-package-names` install for npm completions Selectively reverts 156d4fb9b9b83546ff891e14216330648cd71a07. `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. --- CHANGELOG.md | 5 ++++- share/completions/npm.fish | 27 +++++---------------------- 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c374498c..249c60d8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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` - `ssh` (#4344) - - `yarn` + - `yarn` + +_† 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`)._ -- diff --git a/share/completions/npm.fish b/share/completions/npm.fish index 0ae9dcdc2..ff9731c8d 100644 --- a/share/completions/npm.fish +++ b/share/completions/npm.fish @@ -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