-
Notifications
You must be signed in to change notification settings - Fork 5
/
generate-examples.sh
executable file
·48 lines (38 loc) · 1.07 KB
/
generate-examples.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
42
43
44
45
46
47
48
#!/bin/bash
set -euo pipefail
rundir=$(dirname $0)
cookiecutter_directory="$1"
default="${cookiecutter_directory}/examples/default"
repository_root="$(git rev-parse --show-toplevel)"
function generate_example() {
example="$1"
echo "Generating ${example}"
rm -rf "${example}/output"
poetry run cookiecutter \
--no-input \
--verbose \
--config-file "${example}/cookiecutter.yaml" \
--output-dir "${example}/output" \
--directory "${cookiecutter_directory}" \
--overwrite-if-exists \
"${repository_root}"
}
poetry install
generate_example "${default}"
for example in $(find "${cookiecutter_directory}/examples" -maxdepth 1 -mindepth 1 -type d); do
if [[ "x${example}" == "x${default}" ]]; then
continue
fi
generate_example "${example}"
# Dedupe via symlink
rdfind \
-checksum sha256 \
-makesymlinks true \
-makeresultsfile false \
"${default}/output" \
"${example}/output"
# Make .gitignore a hardlink
find . -type l -name ".gitignore" -exec bash -c 'ln -f "$(readlink "$0")" "$0"' {} \;
# Make symlinks relative
symlinks -cr "${example}/output"
done