Browse Source

Add comments

pull/2/head
Luke Childs 8 years ago
parent
commit
f2644cd55d
  1. 8
      npm-run-completion.zsh

8
npm-run-completion.zsh

@ -1,5 +1,9 @@
_npm_run_completion() { _npm_run_completion() {
# If we're on the run command
if [ "${words[2]}" = "run" ]; then if [ "${words[2]}" = "run" ]; then
# Look for a package.json file
local filename="package.json" local filename="package.json"
local dir=$PWD local dir=$PWD
while [ ! -e "$dir/$filename" ]; do while [ ! -e "$dir/$filename" ]; do
@ -8,10 +12,14 @@ _npm_run_completion() {
break break
fi fi
done done
# If we have one, parse the scripts
if [ ! "$dir" = "" ] && type node > /dev/null; then if [ ! "$dir" = "" ] && type node > /dev/null; then
local options=("${(@f)$(node -e "var pkg = require('$dir/$filename'); pkg.scripts && Object.keys(pkg.scripts).forEach(function(script) { console.log(script.replace(':', '\\\:')+':$ '+pkg.scripts[script]) })")}") local options=("${(@f)$(node -e "var pkg = require('$dir/$filename'); pkg.scripts && Object.keys(pkg.scripts).forEach(function(script) { console.log(script.replace(':', '\\\:')+':$ '+pkg.scripts[script]) })")}")
_describe 'values' options _describe 'values' options
fi fi
# Fall back to default completion for all other npm commands
else else
compadd -- $(COMP_CWORD=$((CURRENT-1)) \ compadd -- $(COMP_CWORD=$((CURRENT-1)) \
COMP_LINE=$BUFFER \ COMP_LINE=$BUFFER \

Loading…
Cancel
Save