lukechilds / zsh-better-npm-completion

Better completion for npm
MIT License
464 stars 35 forks source link

fix `npm install <tab>` completion #16

Open ammmze opened 4 years ago

ammmze commented 4 years ago

Update: I'm not sure when npm switched their cache storage, but it's not as simple as just loading a file list anymore. And npm doesn't expose a way directly to get the cache list, so I had to put a little script together that uses the cacache library that the npm cache uses under the hood to get a package list.

It's not the quickest thing in the world. I just finished setting up a new machine from scratch, so my cache is pretty small and it still takes several seconds to get that list. So I also added the zsh caching mechanism to cache the package list.

This should resolve #9.

Update #2: Perform npm search for packages to install. Include local files to resolve #5

Original: in scenarios where people have ls aliased as ls --color=auto or something can cause errors like this when trying to complete an npm install <tab>:

_values:compvalues:11: invalid value definition: ^[[01;34m_locks^[[0m

So this just helps cover edge cases to prevent this from breaking.

ammmze commented 4 years ago

Oh...but actually just realized npm doesn't appear to have a cache of packages there anymore. Hence #9 ... guess we need to see how to get to npm's newer cache stuff

ammmze commented 4 years ago

The npm cache documentation mentions list...

Used to add, list, or clean the npm cache folder.

But npm cache list is not a valid command :\

Edit: Which explains why someone created this

ammmze commented 4 years ago

Sorry...just pushed another update. It now incorporates an npm search to find packages. And it also includes local files in npm install which should resolve #5