about summary refs log tree commit diff stats
path: root/update_common_files.sh
blob: 9015cc685ea66de747af286a261621511669eda3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env sh

ROOT="$(git rev-parse --show-toplevel)";

# This results in fd returning relative paths
cd "$ROOT/common" || echo "BUG, no root dir!"

fd . "." --type file --hidden | while read -r file; do
    [ -n "$first_run_done" ] && echo
    echo "Instantiating '$file'..."
    fd . "../templates" --type directory --max-depth 1 | while read -r template; do
        echo "   done in '$template'."
        rm "$template$file"
        cp "$file" "$template$file"
    done
    first_run_done=yes
done

# vim: ft=sh