This repository has been archived by the owner on Oct 15, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwundertools
executable file
·54 lines (46 loc) · 1.98 KB
/
wundertools
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env bash
#####
# lib executable for wundertools
#
# This is a centralized executable for wundertools. it is meant to allow
# running wundertools commands from anywhere inside your project.
#
# To use it: move, copy or symlimk it to any PATH location, such as ~/bin/wundertools
# and make sure that it is executable.
#
# subpath that marks a wundertools project
# @NOTE if this is empty it breaks stuff
SUBPATH_WUNDERTOOLS="wundertools"
# path executed from
PATH_EXECUTION="${PATH_EXECUTION:-`pwd`}"
# path to user home folder (in case)
PATH_HOME="${PATH_HOME:-${HOME}}"
# eventually, the path that containers a wundertools folder.
PATH_CONTAINER="${PATH_EXECUTION}"
# Determine project root, and data paths
while [ -n "${PATH_CONTAINER}" ]; do
if [ "${PATH_CONTAINER}" == "${PATH_HOME}" ]; then
echo "Could not find any wundertools project. I looked for a '$SUBPATH_WUNDERTOOLS' folder, all the way to you user home folder, but couldn't find one."
exit 1;
fi
if [ "${PATH_CONTAINER}" == "/" ]; then
echo "Could not find any wundertools project. I looked for a '$SUBPATH_WUNDERTOOLS' folder, all the way to you machine root folder, but couldn't find one."
exit 1;
fi
if [ "${PATH_CONTAINER}" == "" ]; then # #TODO I can't rememeber how to do ors in bash if statements :|
echo "Could not find any wundertools project. I looked for a '$SUBPATH_WUNDERTOOLS' folder, all the way to you machine root folder, but couldn't find one."
exit 1;
fi
if [ -d "${PATH_CONTAINER}/${SUBPATH_WUNDERTOOLS}" ]; then
PATH_WUNDERTOOLS="${PATH_CONTAINER}/${SUBPATH_WUNDERTOOLS}"
break
fi
PATH_CONTAINER="$(dirname "${PATH_CONTAINER}")"
done
#echo "WUNDERTOOLS RUN [PROJECT:${PATH_CONTAINER}][WUNDERTOOLS:${PATH_WUNDERTOOLS}][ARGS: ${@}"
if [ ! -f "${PATH_WUNDERTOOLS}/bootstrap.inc" ]; then
echo "No boostrap found in wundertools root. Expected ${PATH_WUNDERTOOLS}/bootstrap.inc"
exit 1
fi
# Hand off to the bootstrap utility.
source "${PATH_WUNDERTOOLS}/bootstrap.inc" $@