Skip to content

Commit 463a730

Browse files
committed
fix: setup watchers only when needed
1 parent e1712af commit 463a730

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

src/core/context.ts

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -107,24 +107,27 @@ export function createRoutesContext(options: ResolvedOptions) {
107107
)
108108
}),
109109
...(options.experimental.paramParsers?.dir.map((folder) => {
110-
watchers.push(
111-
setupParamParserWatcher(
112-
fsWatch('.', {
113-
cwd: folder,
114-
ignoreInitial: true,
115-
ignorePermissionErrors: true,
116-
ignored: (filePath, stats) => {
117-
// let folders pass, they are ignored by the glob pattern
118-
if (!stats || stats.isDirectory()) {
119-
return false
120-
}
121-
122-
return !isParamParserMatch(relative(folder, filePath))
123-
},
124-
}),
125-
folder
110+
if (startWatchers) {
111+
watchers.push(
112+
setupParamParserWatcher(
113+
fsWatch('.', {
114+
cwd: folder,
115+
ignoreInitial: true,
116+
ignorePermissionErrors: true,
117+
ignored: (filePath, stats) => {
118+
// let folders pass, they are ignored by the glob pattern
119+
if (!stats || stats.isDirectory()) {
120+
return false
121+
}
122+
123+
return !isParamParserMatch(relative(folder, filePath))
124+
},
125+
}),
126+
folder
127+
)
126128
)
127-
)
129+
}
130+
128131
return glob(PARAM_PARSER_GLOB, {
129132
cwd: folder,
130133
onlyFiles: true,

0 commit comments

Comments
 (0)