You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
_npm_run_completion() {
|
|
|
|
if [ "${words[2]}" = "run" ]; then
|
|
|
|
local filename="package.json"
|
|
|
|
local dir=$PWD
|
|
|
|
while [ ! -e "$dir/$filename" ]; do
|
|
|
|
dir=${dir%/*}
|
|
|
|
if [ "$dir" = "" ]; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
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]) })")}")
|
|
|
|
_describe 'values' options
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
compadd -- $(COMP_CWORD=$((CURRENT-1)) \
|
|
|
|
COMP_LINE=$BUFFER \
|
|
|
|
COMP_POINT=0 \
|
|
|
|
npm completion -- "${words[@]}" \
|
|
|
|
2>/dev/null)
|
|
|
|
IFS=$si
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
compdef _npm_run_completion npm
|