Skip to content

Commit c8c81d4

Browse files
committed
feat(useFsWatcher): support patterns as Set
1 parent a3ab1c6 commit c8c81d4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/core/src/composables/useFsWatcher.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export interface UseFSWatcher {
1616
* @reactive `workspace.createFileSystemWatcher`
1717
*/
1818
export function useFsWatcher(
19-
globPattern: MaybeRefOrGetter<GlobPattern | GlobPattern[]>,
19+
globPattern: MaybeRefOrGetter<GlobPattern | readonly GlobPattern[] | ReadonlySet<GlobPattern>>,
2020
ignoreCreateEvents?: MaybeNullableRefOrGetter<boolean>,
2121
ignoreChangeEvents?: MaybeNullableRefOrGetter<boolean>,
2222
ignoreDeleteEvents?: MaybeNullableRefOrGetter<boolean>,
@@ -28,7 +28,11 @@ export function useFsWatcher(
2828

2929
watchEffect(() => {
3030
const globPatternValue = toValue(globPattern)
31-
const newPatterns = Array.isArray(globPatternValue) ? globPatternValue : [globPatternValue]
31+
const newPatterns = Array.isArray(globPatternValue)
32+
? globPatternValue
33+
: globPatternValue instanceof Set
34+
? Array.from(globPatternValue)
35+
: [globPatternValue]
3236
for (const [pattern, watcher] of watchers) {
3337
if (!newPatterns.includes(pattern)) {
3438
watcher.dispose()

0 commit comments

Comments
 (0)