oh-my-fish/pkg/omf/functions/packages/omf.packages.update.fish
2016-07-18 17:57:54 -05:00

31 lines
791 B
Fish

function omf.packages.update -a name
if not set target_path (omf.packages.path $name)
echo (omf::err)"Could not find $name."(omf::off) 1>&2
return 1
end
# Only pull packages in version control
if test -e $target_path/.git
omf.repo.pull $target_path
switch $status
case 0
omf.bundle.install $target_path/bundle
set result (omf::em)"$name successfully updated."(omf::off)
case 1
echo (omf::err)"Could not update $name."(omf::off) 1>&2
return 1
case 2
set result (omf::dim)"$name is already up-to-date."(omf::off)
end
end
# Run update hook.
if not omf.packages.run_hook $target_path update
echo (omf::err)"Could not update $name."(omf::off) 1^&2
return 1
end
echo $result
return 0
end