File tree Expand file tree Collapse file tree 3 files changed +5
-4
lines changed
core/src/types/plugin-api Expand file tree Collapse file tree 3 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -171,16 +171,16 @@ const config: UserConfig<DefaultThemeOptions> = {
171
171
172
172
evergreen : process . env . NODE_ENV !== 'production' ,
173
173
174
- onWatched : ( _ , restart ) => {
174
+ onWatched : ( _ , watchers , restart ) => {
175
175
const watcher = chokidar . watch ( 'configs/**/*.ts' , {
176
176
cwd : __dirname ,
177
177
ignoreInitial : true ,
178
178
} )
179
179
watcher . on ( 'change' , async ( file ) => {
180
180
logger . info ( `file ${ chalk . magenta ( file ) } is modified` )
181
- await watcher . close ( )
182
181
await restart ( )
183
182
} )
183
+ watchers . push ( watcher )
184
184
} ,
185
185
}
186
186
Original file line number Diff line number Diff line change @@ -119,5 +119,5 @@ export const dev = async (
119
119
watchers . push ( configWatcher )
120
120
}
121
121
122
- await app . pluginApi . hooks . onWatched . process ( app , restart )
122
+ await app . pluginApi . hooks . onWatched . process ( app , watchers , restart )
123
123
}
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import type { Page } from '../page'
4
4
5
5
// util type
6
6
type PromiseOrNot < T > = Promise < T > | T
7
+ type Closable = { close ( ) : void }
7
8
8
9
// base hook type
9
10
export type Hook <
@@ -51,7 +52,7 @@ export type ExtendsPageDataHook = Hook<
51
52
export interface Hooks {
52
53
onInitialized : LifeCycleHook
53
54
onPrepared : LifeCycleHook
54
- onWatched : LifeCycleHook < [ restart : ( ) => Promise < void > ] >
55
+ onWatched : LifeCycleHook < [ watchers : Closable [ ] , restart : ( ) => Promise < void > ] >
55
56
onGenerated : LifeCycleHook
56
57
extendsMarkdown : ExtendsMarkdownHook
57
58
extendsPageData : ExtendsPageDataHook
You can’t perform that action at this time.
0 commit comments