-
Notifications
You must be signed in to change notification settings - Fork 40
/
mini-moul.sh
executable file
·41 lines (35 loc) · 958 Bytes
/
mini-moul.sh
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
#!/bin/bash
source ~/mini-moulinette/mini-moul/config.sh
# assignment name
assignment=NULL
function handle_sigint {
echo "${RED}Script aborted by user. Cleaning up..."
rm -R ../mini-moul
echo ""
echo "${GREEN}Cleaning process done.${DEFAULT}"
exit 1
}
# Function to determine if current directory matches a pattern
detect_assignment() {
assignment=$(basename "$(pwd)")
[[ $assignment =~ ^C(0[0-9]|1[0-3])$ ]]
}
if detect_assignment; then
cp -R ~/mini-moulinette/mini-moul mini-moul
run_norminette
trap handle_sigint SIGINT
cd mini-moul
./test.sh "$assignment"
rm -R ../mini-moul
else
printf "${RED}Current directory does not match expected pattern (C[00~13]).${DEFAULT}\n"
printf "${RED}Please navigate to an appropriate directory to run tests.${DEFAULT}\n"
fi
exit 1
run_norminette() {
if command -v norminette &> /dev/null; then
norminette
else
echo "norminette not found, skipping norminette checks"
fi
}