diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-04-02 14:05:21 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-04-02 14:05:21 +0200 |
commit | fa92afbf1edc7fabaa1321dd9a3483dc73d24bf0 (patch) | |
tree | f3602bfdc7c76e57afbf898a0aecfd985e4bc973 /common/files | |
parent | feat(treewide): Also remove hard-coded values in the `templates/` dir (diff) | |
download | flake-templates-fa92afbf1edc7fabaa1321dd9a3483dc73d24bf0.tar.gz flake-templates-fa92afbf1edc7fabaa1321dd9a3483dc73d24bf0.zip |
feat(common/init): Add support for replacing the variables in file names
Diffstat (limited to 'common/files')
-rwxr-xr-x | common/files/init | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/common/files/init b/common/files/init index 4f108ef..8e3479f 100755 --- a/common/files/init +++ b/common/files/init @@ -79,6 +79,12 @@ while read -r var; do var_value="${var_value%\"}" fd . --hidden --type file --exec sed --in-place "s|%\bINIT_$var_name\b|$var_value|" + + # Replace the variable in file paths + fd "%INIT_$var_name" . --hidden | while read -r file_path; do + new_file_path="$(echo "$file_path" | sed "s|%INIT_$var_name|$var_value|")"; + mv "$file_path" "$new_file_path" + done done < "$replacement_file" # HACK: Re-add the executable permissions to files, which the nix template has somehow |