Skip to content

Commit aab7161

Browse files
committed
feat(sentinels): add Xcode DerivedData exclusion with glob sentinel support
Add glob pattern support for sentinel definitions so wildcards like *.xcodeproj can be used. Sentinels containing '*' use sh -c with ls -d for glob expansion instead of test -e, with no performance impact. Add DerivedData *.xcodeproj entry to exclude Xcode build artifacts when an Xcode project is present alongside the DerivedData directory. Inspired by stevegrunwell#64 (props @mdab121).
1 parent 64834be commit aab7161

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
88

99
### Added
1010

11+
* Support glob patterns in sentinel definitions, enabling wildcards like `*.xcodeproj` ([stevegrunwell/asimov#64], props @mdab121)
12+
* Exclude Xcode DerivedData when `*.xcodeproj` is present ([stevegrunwell/asimov#64], props @mdab121)
1113
* Exclude Next.js build cache (`.next`)
1214
* Exclude Nuxt build cache (`.nuxt`)
1315
* Exclude Angular CLI cache (`.angular`)
@@ -117,3 +119,4 @@ Initial public release.
117119
[#55]: https://github.com/stevegrunwell/asimov/pull/55
118120
[#35]: https://github.com/stevegrunwell/asimov/pull/35
119121
[#56]: https://github.com/stevegrunwell/asimov/pull/56
122+
[stevegrunwell/asimov#64]: https://github.com/stevegrunwell/asimov/pull/64

asimov

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ readonly ASIMOV_VENDOR_DIR_SENTINELS=(
4949
'.venv pyproject.toml' # virtualenv (Python)
5050
'Carthage Cartfile' # Carthage
5151
'Pods Podfile' # CocoaPods
52+
'DerivedData *.xcodeproj' # Xcode DerivedData
5253
'bower_components bower.json' # Bower (JavaScript)
5354
'build build.gradle' # Gradle
5455
'build build.gradle.kts' # Gradle Kotlin Script
@@ -130,10 +131,20 @@ for i in "${ASIMOV_VENDOR_DIR_SENTINELS[@]}"; do
130131
#
131132
# For example, when looking at a /vendor directory, we may choose to
132133
# ensure a composer.json file is available.
134+
#
135+
# Sentinels containing wildcards (e.g. *.xcodeproj) use glob expansion
136+
# via sh -c instead of a plain `test -e`.
137+
# Glob support inspired by stevegrunwell/asimov#64 (props @mdab121).
138+
if [[ "$_sibling_sentinel_name" == *'*'* ]]; then
139+
_sentinel_check=( -execdir sh -c 'ls -d '"${_sibling_sentinel_name}"' >/dev/null 2>&1' \; )
140+
else
141+
_sentinel_check=( -execdir test -e "${_sibling_sentinel_name}" \; )
142+
fi
143+
133144
find_parameters_vendor+=( -or \( \
134145
-type d \
135146
-name "${_exclude_name}" \
136-
-execdir test -e "${_sibling_sentinel_name}" \; \
147+
"${_sentinel_check[@]}" \
137148
-prune \
138149
-print \
139150
\) )

tests/behavior.bats

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ load test_helper
3636
[[ "$(count_exclusions)" -eq 0 ]]
3737
}
3838

39+
@test "does not exclude DerivedData without *.xcodeproj" {
40+
mkdir -p "${HOME}/Code/My-Project/DerivedData"
41+
run_asimov
42+
refute_excluded "${HOME}/Code/My-Project/DerivedData"
43+
[[ "$(count_exclusions)" -eq 0 ]]
44+
}
45+
3946
# =============================================================================
4047
# Multi-match and deduplication
4148
# =============================================================================

tests/sentinels.bats

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,14 @@ load test_helper
165165
[[ "$(count_exclusions)" -eq 1 ]]
166166
}
167167

168+
@test "Xcode: excludes DerivedData when *.xcodeproj is present" {
169+
mkdir -p "${HOME}/Code/My-Project/DerivedData"
170+
mkdir -p "${HOME}/Code/My-Project/MyApp.xcodeproj"
171+
run_asimov
172+
assert_excluded "${HOME}/Code/My-Project/DerivedData"
173+
[[ "$(count_exclusions)" -eq 1 ]]
174+
}
175+
168176
# --- JavaScript ---
169177

170178
@test "Bower: excludes bower_components when bower.json is present" {

0 commit comments

Comments
 (0)