Skip to content

Commit 094bd50

Browse files
committed
script covers more cases
1 parent d2fe015 commit 094bd50

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

scripts/testdata_version.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ VERSION_ARGUMENT=$1
1616

1717
# Find and replace the string in all .tf files in the ./testdata/ directory
1818
find ./testdata/ -type f -name "*.tf" -exec sed -i.bak "/coder = {/{
19+
# Capture the entire coder block
20+
:a
1921
N
22+
/}/!ba
2023
# Remove any existing version lines
2124
s|[ ]*version[ ]*=[^\\n]*\\n||g
22-
# Add the new version line
23-
s| coder = {| coder = {\n version = \"$VERSION_ARGUMENT\"|
24-
# Ensure the source line is correctly formatted
25-
s|source[ ]*=[ ]*\"coder/coder\"|source = \"coder/coder\"|
26-
s|source[ ]*\"coder/coder\"|source = \"coder/coder\"|
25+
# Replace the coder block with the new format
26+
s| coder = {\n.*}| coder = {\n source = \"coder/coder\"\n version = \"$VERSION_ARGUMENT\"\n }|
2727
}" {} +
2828

2929
# Remove backup files
3030
find ./testdata/ -type f -name "*.bak" -exec rm {} +
3131

32-
echo "Replacement complete. Backup files have been removed."
32+
echo "Replacement complete."

0 commit comments

Comments
 (0)