Skip to content

Commit 4c388b6

Browse files
authored
Merge pull request #426 from wasp-lang/franjo/fix-macos-patch
2 parents 48cfd62 + 6afc6fb commit 4c388b6

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

opensaas-sh/README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,10 @@ If you're running the `patch.sh` or `diff.sh` scripts on Mac, you need to instal
2626
- `gpatch`,
2727
- and `diffutils`.
2828

29-
You should also create aliases for `realpath` and `patch`:
30-
3129
```sh
3230
brew install coreutils # contains grealpath
3331
brew install gpatch
3432
brew install diffutils
35-
36-
echo 'alias realpath="grealpath"' >> ~/.zshrc
37-
echo 'alias patch="gpatch"' >> ~/.zshrc
38-
source ~/.zshrc
3933
```
4034

4135
Make sure not to commit `app/` to git. It is currently (until we resolve this) not added to .gitignore because that messes up diffing for us.

opensaas-sh/tools/dope.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@
55
# Allows you to easily create a diff between the two projects (base and derived), or to patch those diffs onto the base project to get the derived one.
66
# Useful when derived project has only small changes on top of base project and you want to keep it in a dir in the same repo as main project.
77

8+
# Determine the patch command to use based on OS
9+
PATCH_CMD="patch"
10+
if [[ "$(uname)" == "Darwin" ]]; then
11+
# On macOS, require gpatch to be installed
12+
if command -v gpatch &> /dev/null; then
13+
PATCH_CMD="gpatch"
14+
else
15+
echo "Error: GNU patch (gpatch) not found. On MacOS, this script requires GNU patch."
16+
echo "Install it with: brew install gpatch"
17+
exit 1
18+
fi
19+
fi
20+
821
# List all the source files in the specified dir.
922
# "Source" files are any files that are not gitignored.
1023
list_source_files() {
@@ -92,7 +105,7 @@ recreate_derived_dir() {
92105

93106
local patch_output
94107
local patch_exit_code
95-
patch_output=$(patch --no-backup-if-mismatch --merge "${DERIVED_DIR}/${derived_filepath}" < "${diff_filepath}")
108+
patch_output=$("${PATCH_CMD}" --no-backup-if-mismatch --merge "${DERIVED_DIR}/${derived_filepath}" < "${diff_filepath}")
96109
patch_exit_code=$?
97110
if [ ${patch_exit_code} -eq 0 ]; then
98111
echo "${patch_output}"

0 commit comments

Comments
 (0)