Skip to content

Commit a819299

Browse files
authored
Check for a taskfile in the current and parent directories (#1)
1 parent c87a22f commit a819299

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

bin/task

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@ RED=$(printf '\033[31m')
1111
RESET=$(printf '\033[0m')
1212

1313
while [ -d $CURRENT_DIR ] && [ $CURRENT_DIR != '/' ]; do
14-
cd $CURRENT_DIR
15-
16-
if [ ! -f ./Taskfile ]
14+
if [ -f ./Taskfile ]
1715
then
18-
echo -e "${RED}ERROR: ${RESET}./Taskfile not found in this directory."
19-
exit 1
16+
# Taskfile found, execute the given task
17+
./Taskfile $@
18+
exit $?
19+
else
20+
# Taskfile not found, trying the parent directory
21+
cd ../
22+
CURRENT_DIR=$(pwd)
2023
fi
21-
22-
./Taskfile $@
23-
exit $?
2424
done
25+
26+
echo -e "${RED}ERROR: ${RESET}./Taskfile not found in the current or parent directories."
27+
exit 1

0 commit comments

Comments
 (0)