install: refactor deploy() to be more readable

This commit is contained in:
Fernando Schauenburg 2021-11-22 09:11:31 +01:00
parent 25a0fd2437
commit ab7d7241d4

View file

@ -162,16 +162,13 @@ equal_content() {
dry_run || cp -f "$2" "$1"
}
# Deploy package by creating subdirs and symlinks to dotfiles.
deploy() {
find "$1" -type f | while read src; do
src_dir="$(dirname "$src")"
dest_dir="$HOME${src_dir##"$1"}"
ensure_directory "$dest_dir"
filename="$(basename "$src")"
[ "$filename" = '.keep' ] && continue
link "$dest_dir/$filename" "$src"
package="$1"
find "$package" -type f | while read dotfile; do
link="$HOME/${dotfile##"$package"/}"
ensure_directory "$(dirname "$link")"
[ "$(basename "$dotfile")" = '.keep' ] || link "$link" "$dotfile"
done
}