Created
October 18, 2017 15:56
-
-
Save burtlo/89dc7d025d1ab484c2468740aadbe87e to your computer and use it in GitHub Desktop.
A script to help run packages that are built within the Habitat Studio.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# run pkg_name HEAD | |
# run pkg_name HEAD~1 | |
function run() { | |
local pkg_name=$1 | |
local pkg_position=$2 | |
local found_pkgs=( ./results/$HAB_ORIGIN-$pkg_name-*.hart ) | |
local pkg_count=${#found_pkgs[@]} | |
declare -A indexed_pkgs | |
for i in ${!found_pkgs[@]}; do | |
((current_count=pkg_count-1-i)) | |
if [ $current_count == 0 ] ; then | |
head_offset="HEAD" | |
else | |
head_offset="HEAD~$current_count" | |
fi | |
indexed_pkgs+=([$head_offset]=${found_pkgs[$i]}) | |
done | |
local pkg_to_run=${indexed_pkgs[$pkg_position]} | |
if [ -z "$pkg_to_run" ] ; then | |
echo "Could not find a package at $pkg_position. There are $pkg_count total package(s)." | |
return | |
fi | |
echo "Running $pkg_to_run" | |
hab sup start $pkg_to_run | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment