Skip to content

Commit

Permalink
add colours
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabe Dunn committed Jul 8, 2021
1 parent 3cecedc commit 1a683f0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 7 additions & 7 deletions functions/yup
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ yup () {
elif (( $+commands[npm] )); then
local pm_cmd="npm install"
else
echo "yarn or npm not found, exiting..."
echo "$fg[red]yarn or npm not found, exiting...$reset_color"
return 1
fi

# make sure jq is installed
if (( ! $+commands[jq] )); then
echo "jq not found, exiting..."
echo "$fg[red]jq not found, exiting...$reset_color"
return 1
fi

# make sure there's a package.json in the current directory
if ! test -f "./package.json"; then
echo "no package.json file in current directory, exiting..."
echo "$fg[red]no package.json file in current directory, exiting...$reset_color"
return 1
fi

Expand Down Expand Up @@ -62,15 +62,15 @@ eof

# if there aren't any dependencies, exit the function
if test -z "$deps"; then
echo "no $scope in package.json"
echo "$fg[blue]no $scope in package.json$reset_color"
return 0
fi

# set the command to run
local cmd_to_run="$pm_cmd $deps"

# run the command
echo "Updating $scope..."
echo "$fg_bold[blue]Updating $scope...$reset_color"
eval "$cmd_to_run"

# if the both arg was passed, run the command again, but for devDependencies
Expand All @@ -84,15 +84,15 @@ eof

# if there aren't any dependencies, exit the function
if test -z "$deps"; then
echo "no $scope in package.json"
echo "$fg[blue]no $scope in package.json$reset_color"
return 0
fi

# set the command to run
cmd_to_run="$pm_cmd $deps"

# run the command
echo "Updating $scope..."
echo "$fg_bold[blue]Updating $scope...$reset_color"
eval "$cmd_to_run"
fi

Expand Down
4 changes: 4 additions & 0 deletions zsh-yup.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

# zsh plugin to update all dependencies of a yarn/npm project

# load colours
autoload -Uz colors
colors

# add the functions to the function path & autoload them
fpath+=("$(dirname ${0})/functions")
autoload -Uz yup
Expand Down

0 comments on commit 1a683f0

Please sign in to comment.