Skip to content

Commit 75f6098

Browse files
authored
WatcherFactory: Add support for exclude and ignore options. (#116)
1 parent 3e61826 commit 75f6098

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,18 @@ watch:
124124
directories:
125125
- src
126126
- tests
127+
exclude:
128+
- lib
127129
fileMask: '*.php'
130+
ignoreDotFiles: true
131+
ignoreVCS: true
132+
ignoreVCSIgnored: false
128133
```
129134

135+
See [the documentation for Finder](https://symfony.com/doc/current/components/finder.html) for more details.
136+
137+
If you experience performance delays with large repositories, try adding `exclude` entries for any large subdirectories that you don't need to watch. Enabling the `ignore...` options can also be helpful. It's also important to ensure you're also using the `'*.php'` file mask.
138+
130139
### Desktop notifications
131140

132141
By default the tool will display desktop notifications whenever the tests pass or fail. If you want to disable certain desktop notifications update `.phpunit-watcher.yml` by adding a `notifications` key.

src/WatcherFactory.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ public static function create(array $options = []): array
1919
}
2020

2121
$finder = (new Finder())
22-
->ignoreDotFiles(false)
23-
->ignoreVCS(false)
22+
->ignoreDotFiles($options['watch']['ignoreDotFiles'])
23+
->ignoreVCS($options['watch']['ignoreVCS'])
24+
->ignoreVCSIgnored($options['watch']['ignoreVCSIgnored'])
2425
->name($options['watch']['fileMask'])
2526
->files()
27+
->exclude($options['watch']['exclude'])
2628
->in($options['watch']['directories']);
2729

2830
$watcher = new Watcher($finder, $options);
@@ -39,6 +41,10 @@ public static function getDefaultOptions(): array
3941
'src',
4042
'tests',
4143
],
44+
'exclude' => [],
45+
'ignoreDotFiles' => false,
46+
'ignoreVCS' => false,
47+
'ignoreVCSIgnored' => false,
4248
'fileMask' => '*.php',
4349
],
4450
'notifications' => [

0 commit comments

Comments
 (0)