From af7f13f059e93c313b6c0336794bb8e9e1f4e346 Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Wed, 29 Jun 2016 23:54:50 +0100 Subject: [PATCH] Wrap code in function --- npm-run-completion.zsh | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) 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 +}