Compare commits

..

6 Commits

Author SHA1 Message Date
T. R. Bernstein
134e4e152d Implement watch exclusion lists
Some checks failed
Docs / docs (push) Has been cancelled
Docs / deploy (push) Has been cancelled
Allow exclusion of directories when watching recursively.
2026-03-15 22:46:59 +01:00
T. R. Bernstein
c87099e4a7 Add SwiftPackageIndex configuration file 2026-03-15 22:46:59 +01:00
T. R. Bernstein
914bbe3153 Add GitHub workflow file to generate docs 2026-03-15 22:46:59 +01:00
T. R. Bernstein
a30e954737 Update README section about docs generation
Show how to generate the Docc docs using task CLI instead of faning out
to swift package docc plugin.
2026-03-15 22:46:59 +01:00
T. R. Bernstein
e2bfb8280b Add generate-docs command to build task
The Swift Docc has to run in a Linux container to be able to build the
documentation, as it needs access to the inotify.h header files.
2026-03-15 22:46:59 +01:00
T. R. Bernstein
e78e2c082d Add open source documentation files 2026-03-15 22:46:55 +01:00
3 changed files with 43 additions and 1 deletions

View File

@@ -75,6 +75,24 @@ try await inotify.addWatchWithAutomaticSubtreeWatching(
This is the most convenient option when you need full coverage of a growing directory tree.
## Excluding Items
You can tell the `Inotify` actor to ignore certain file or directory names. Excluded names are skipped during recursive directory resolution (so no watch is installed on them) and silently dropped from the event stream:
```swift
let inotify = try Inotify()
// Ignore version-control and build directories
await inotify.exclude(names: ".git", "node_modules", ".build")
try await inotify.addWatchWithAutomaticSubtreeWatching(
forDirectory: "/home/user/project",
mask: [.create, .modify, .delete]
)
```
Use `isExcluded(_:)` to check whether a name is currently on the exclusion list.
## Event Masks
`InotifyEventMask` is an `OptionSet` that mirrors the native inotify flags. You can combine them freely.
@@ -113,7 +131,9 @@ try inotify.removeWatch(wd)
## Build Tool
The package ships with a `task` executable (the `TaskCLI` target) that serves as the project's build tool. It spins up a Docker container running `swift:latest` on Linux and executes the full test suite inside it, so you can validate everything on the correct platform even when developing on macOS.
The package ships with a `task` executable (the `TaskCLI` target) that serves as the project's build tool. It automates running tests and generating documentation inside Linux Docker containers, so you can validate everything on the correct platform even when developing on macOS.
### Tests
```bash
swift run task test

View File

@@ -20,6 +20,8 @@ Beyond single-directory watches, the library provides two higher-level methods f
- ``Inotify/Inotify/addRecursiveWatch(forDirectory:mask:)`` installs watches on every existing subdirectory at setup time.
- ``Inotify/Inotify/addWatchWithAutomaticSubtreeWatching(forDirectory:mask:)`` does the same **and** automatically watches subdirectories that are created after setup.
You can also exclude certain file or directory names so that they are skipped during directory resolution and silently dropped from the event stream. See ``Inotify/Inotify/exclude(names:)`` and <doc:WatchingDirectoryTrees> for details.
All public types conform to `Sendable`, so they can be safely passed across concurrency boundaries.
## Topics
@@ -30,6 +32,10 @@ All public types conform to `Sendable`, so they can be safely passed across conc
- ``InotifyEvent``
- ``InotifyEventMask``
### Articles
- <doc:WatchingDirectoryTrees>
### Errors
- ``InotifyError``

View File

@@ -33,6 +33,22 @@ let descriptors = try await inotify.addWatchWithAutomaticSubtreeWatching(
Internally this listens for `CREATE` events carrying the ``InotifyEventMask/isDir`` flag and installs a new watch with the same mask whenever a subdirectory appears.
### Excluding Directories
When watching large trees you often want to skip certain subdirectories entirely — version-control metadata, build artefacts, dependency caches, and so on. Call ``Inotify/Inotify/exclude(names:)`` **before** adding a recursive or automatic-subtree watch:
```swift
let inotify = try Inotify()
await inotify.exclude(names: ".git", "node_modules", ".build")
try await inotify.addWatchWithAutomaticSubtreeWatching(
forDirectory: "/home/user/project",
mask: .allEvents
)
```
Excluded names are matched against the last path component of each directory during resolution and are also filtered from the event stream, so you never receive events for items whose name is on the exclusion list.
### Choosing the Right Method
| Method | Covers existing subdirectories | Covers new subdirectories |