From fa92afbf1edc7fabaa1321dd9a3483dc73d24bf0 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Tue, 2 Apr 2024 14:05:21 +0200 Subject: feat(common/init): Add support for replacing the variables in file names --- common/files/init | 6 ++++++ templates/awk/src/%INIT_APPLICATION_NAME.awk | 4 ++++ templates/awk/src/TODO.awk | 4 ---- 3 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 templates/awk/src/%INIT_APPLICATION_NAME.awk delete mode 100644 templates/awk/src/TODO.awk 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 diff --git a/templates/awk/src/%INIT_APPLICATION_NAME.awk b/templates/awk/src/%INIT_APPLICATION_NAME.awk new file mode 100644 index 0000000..78b2356 --- /dev/null +++ b/templates/awk/src/%INIT_APPLICATION_NAME.awk @@ -0,0 +1,4 @@ +#!/usr/bin/env -S gawk -f +BEGIN { + printf ("Hello World!\n"); +} diff --git a/templates/awk/src/TODO.awk b/templates/awk/src/TODO.awk deleted file mode 100644 index 78b2356..0000000 --- a/templates/awk/src/TODO.awk +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env -S gawk -f -BEGIN { - printf ("Hello World!\n"); -} -- cgit 1.4.1