aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/formatters/apheleia-mix22
1 files changed, 22 insertions, 0 deletions
diff --git a/scripts/formatters/apheleia-mix b/scripts/formatters/apheleia-mix
new file mode 100755
index 0000000..d2038e1
--- /dev/null
+++ b/scripts/formatters/apheleia-mix
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+
+# This function prints the name of the current directory if it
+# contains a file or directory named after the first argument, or the
+# parent directory if it contains such a file, or the parent's parent,
+# and so on. If no such file is found it returns nonzero.
+# https://unix.stackexchange.com/a/22215
+find_upwards() {
+ fname="$1"
+
+ path="${PWD}"
+ while [[ -n "${path}" && ! -e "${path}/${fname}" ]]; do
+ path="${path%/*}"
+ done
+ [[ -n "${path}" ]] && echo "${path}"
+}
+
+if dir="$(find_upwards .formatter.exs)"; then
+ cd -- "${dir}" || exit
+fi
+
+exec mix "$@"