Skip to content

Commit 8c486af

Browse files
Copilotrfay
andauthored
Fix setup-template.sh macOS compatibility with cross-platform sed approach (#4)
Co-authored-by: rfay <112444+rfay@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent a842a6f commit 8c486af

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

setup-template.sh

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,25 @@ TITLE=${TITLE:-"Presentation Title"}
4343
echo
4444
echo "📝 Updating files..."
4545

46+
# Function to replace text in files (cross-platform)
47+
replace_in_file() {
48+
local file=$1
49+
local pattern=$2
50+
local replacement=$3
51+
sed "s|$pattern|$replacement|g" "$file" > "$file.tmp" && mv "$file.tmp" "$file"
52+
}
53+
4654
# Update README.md
47-
sed -i "s|YOUR-USERNAME|$OWNER|g" README.md
48-
sed -i "s|YOUR-REPO-NAME|$REPO|g" README.md
49-
sed -i "s|Presentation Title|$TITLE|g" README.md
55+
replace_in_file README.md "YOUR-USERNAME" "$OWNER"
56+
replace_in_file README.md "YOUR-REPO-NAME" "$REPO"
57+
replace_in_file README.md "Presentation Title" "$TITLE"
5058

5159
# Update index.html
52-
sed -i "s|Presentation Title|$TITLE|g" index.html
53-
sed -i "s|slides/presentation.md|slides/$REPO.md|g" index.html
60+
replace_in_file index.html "Presentation Title" "$TITLE"
61+
replace_in_file index.html "slides/presentation.md" "slides/$REPO.md"
5462

5563
# Update package.json
56-
sed -i "s|\"name\": \"presentation-template\"|\"name\": \"$REPO\"|g" package.json
64+
replace_in_file package.json "\"name\": \"presentation-template\"" "\"name\": \"$REPO\""
5765

5866
# Rename the markdown file
5967
if [ -f "slides/presentation.md" ]; then

0 commit comments

Comments
 (0)