From a5b474b1bfd829bce3c467ac4af41d50c1c7dbc2 Mon Sep 17 00:00:00 2001 From: Serge Guzik Date: Mon, 11 Feb 2019 16:37:46 +0200 Subject: [PATCH] feat: Check dependencies --- warp4j | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/warp4j b/warp4j index 5ef140d..aab9d20 100755 --- a/warp4j +++ b/warp4j @@ -62,6 +62,30 @@ function get_this_platform() { THIS_PLATFORM=$(get_this_platform) +# check if all dependencies available +function check_deps() { + local deps=("warp-packer" \ + "curl" \ + "awk" \ + "sed") + local missing=() + for d in ${deps[@]}; do + if ! command -v $d &> /dev/null ; then + missing+=($d) + fi + done + if [[ $missing ]]; then + echo -n "Error: Missing dependencies: " >&2 + for d in ${missing[@]}; do + echo -n "$d " >&2 + done + echo >&2 + fail + fi +} + +check_deps + if [[ $# -eq 0 ]]; then print_help exit