summaryrefslogtreecommitdiffhomepage
path: root/scripts/utils
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/utils')
-rwxr-xr-xscripts/utils/gh-ready-check22
-rwxr-xr-xscripts/utils/print-and-run9
2 files changed, 31 insertions, 0 deletions
diff --git a/scripts/utils/gh-ready-check b/scripts/utils/gh-ready-check
new file mode 100755
index 0000000000..164b5de903
--- /dev/null
+++ b/scripts/utils/gh-ready-check
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+
+# This script controls that the gh (GitHub CLI) command is installed and authenticated. This can be
+# called in the beginning of all scripts depending on gh.
+
+set -eu
+
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+cd "$SCRIPT_DIR"
+
+# shellcheck source=scripts/utils/log
+source ./log
+
+if ! command -v gh > /dev/null; then
+ log_error "gh (GitHub CLI) is required to run this script"
+ exit 1
+fi
+
+if ! gh auth status > /dev/null; then
+ log_error "Authentication through gh (GitHub CLI) is required to run this script"
+ exit 1
+fi
diff --git a/scripts/utils/print-and-run b/scripts/utils/print-and-run
new file mode 100755
index 0000000000..b323040f3c
--- /dev/null
+++ b/scripts/utils/print-and-run
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+
+# This is a small utility script that can be sourced to provide a function that prints its arguments
+# and then calls them as a command, e.g. `print_and_run sleep 5`.
+
+function print_and_run {
+ echo "+ $*"
+ "$@"
+}