Skip to content

Commit a7f05ae

Browse files
authored
Fix fill_template.sh on MacOS (#188)
- closes #187 - closes #164 I just asked chatgpt to fix it and the changes seem reasonable 😬 Works on my mac now. Haven't tested it on linux but I assume it still works there.
1 parent 17bcd1a commit a7f05ae

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

fill_template.sh

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,34 @@
33
set -e
44

55
echo "To fill the template tell me your egui project crate name: "
6-
76
read crate
87

98
echo "To fill the template tell me your name (for author in Cargo.toml): "
10-
119
read name
1210

1311
echo "To fill the template tell me your e-mail address (also for Cargo.toml): "
14-
1512
read email
1613

1714
echo "Patching files..."
1815

19-
sed -i "s/eframe_template/$crate/g" Cargo.toml
20-
sed -i "s/eframe_template/$crate/g" src/main.rs
21-
sed -i "s/eframe template/$crate/g" index.html
22-
sed -i "s/eframe_template/$crate/g" assets/sw.js
23-
sed -i "s/Emil Ernerfeldt/$name/g" Cargo.toml
24-
sed -i "s/emil.ernerfeldt@gmail.com/$email/g" Cargo.toml
16+
# Determine the correct sed syntax based on OS
17+
if [ "$(uname)" = "Darwin" ]; then
18+
# macOS sed
19+
sed_inplace() {
20+
sed -i '' "$@"
21+
}
22+
else
23+
# GNU sed (Linux)
24+
sed_inplace() {
25+
sed -i "$@"
26+
}
27+
fi
28+
29+
sed_inplace "s/eframe_template/$crate/g" Cargo.toml
30+
sed_inplace "s/eframe_template/$crate/g" src/main.rs
31+
sed_inplace "s/eframe template/$crate/g" index.html
32+
sed_inplace "s/eframe_template/$crate/g" assets/sw.js
33+
sed_inplace "s/Emil Ernerfeldt/$name/g" Cargo.toml
34+
sed_inplace "s/emil.ernerfeldt@gmail.com/$email/g" Cargo.toml
2535

2636
echo "Done."
27-

0 commit comments

Comments
 (0)