diff --git a/npm-run-completion.zsh b/npm-run-completion.zsh index 6a3bef2..1740c32 100644 --- a/npm-run-completion.zsh +++ b/npm-run-completion.zsh @@ -1,11 +1,13 @@ -filename="package.json" -dir=$PWD -while [ ! -e "$dir/$filename" ]; do - dir=${dir%/*} - if [ "$dir" = "" ]; then - break; +_npm_run_completion() { + local filename="package.json" + local dir=$PWD + while [ ! -e "$dir/$filename" ]; do + dir=${dir%/*} + if [ "$dir" = "" ]; then + break; + fi + done + if [ ! "$dir" = "" ]; then + echo "$dir/$filename"; fi -done -if [ ! "$dir" = "" ]; then - echo "$dir/$filename"; -fi +}