File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed
Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ export interface Shortcut {
1111 action : ( ) => void | Promise < void >
1212}
1313
14- export function shortcuts ( restart : ( ) => void ) : void {
14+ export function shortcuts ( restart : ( ) => void ) : ( ) => void {
1515 let actionRunning = false
1616 async function onInput ( input : string ) {
1717 if ( actionRunning ) return
@@ -20,7 +20,6 @@ export function shortcuts(restart: () => void): void {
2020 key : 'r' ,
2121 description : 'reload config and rebuild' ,
2222 action ( ) {
23- rl . close ( )
2423 restart ( )
2524 } ,
2625 } ,
@@ -72,4 +71,5 @@ export function shortcuts(restart: () => void): void {
7271 input : process . stdin ,
7372 } )
7473 rl . on ( 'line' , onInput )
74+ return ( ) => rl . close ( )
7575}
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ export async function build(userOptions: Options = {}): Promise<void> {
3636 const rebuilds = await Promise . all (
3737 configs . map ( ( options ) => buildSingle ( options , clean ) ) ,
3838 )
39- const disposeCbs : ( ( ) => Promise < void > ) [ ] = [ ]
39+ const disposeCbs : ( ( ) => void | Promise < void > ) [ ] = [ ]
4040
4141 for ( const [ i , config ] of configs . entries ( ) ) {
4242 const rebuild = rebuilds [ i ]
@@ -46,8 +46,9 @@ export async function build(userOptions: Options = {}): Promise<void> {
4646 disposeCbs . push ( ( ) => watcher . close ( ) )
4747 }
4848
49+ // Watch mode with shortcuts
4950 if ( disposeCbs . length ) {
50- shortcuts ( restart )
51+ disposeCbs . push ( shortcuts ( restart ) )
5152 }
5253
5354 async function restart ( ) {
You can’t perform that action at this time.
0 commit comments