Skip to content

Commit

Permalink
feat: add an option to disable file watching (#387)
Browse files Browse the repository at this point in the history
* feat: add an option to disable file watching

* feat: disable watchers only based on the `CI` env var
  • Loading branch information
tamasfe committed May 20, 2024
1 parent ca71122 commit 13f93fc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ export default createUnplugin<Options | undefined>((opt = {}, _meta) => {
},

buildStart() {
// TODO: how do we properly check if we are in dev mode?
return ctx.scanPages(true)
return ctx.scanPages(options.watch)
},

buildEnd() {
Expand Down
10 changes: 10 additions & 0 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,15 @@ export interface ResolvedOptions {
* @inheritDoc ParseSegmentOptions
*/
pathParser: ParseSegmentOptions

/**
* Whether to watch the files for changes.
*
* Defaults to `true` unless the `CI` environment variable is set.
*
* @default `!process.env.CI`
*/
watch: boolean
}

/**
Expand Down Expand Up @@ -210,6 +219,7 @@ export const DEFAULT_OPTIONS: ResolvedOptions = {
pathParser: {
dotNesting: true,
},
watch: !process.env.CI,
}

export interface ServerContext {
Expand Down

0 comments on commit 13f93fc

Please sign in to comment.