@@ -112,25 +112,35 @@ export class Dev extends Dispose {
112
112
113
113
constructor ( ) {
114
114
super ( ) ;
115
- const cmdId = `${ cmdPrefix } .run` ;
116
- this . push ( commands . registerCommand ( cmdId , this . execute , this ) ) ;
117
- this . push (
118
- ( function ( ) {
119
- commands . titles . set ( cmdId , 'Run flutter server' ) ;
120
- return {
121
- dispose ( ) {
122
- commands . titles . delete ( cmdId ) ;
123
- } ,
124
- } ;
125
- } ) ( ) ,
126
- ) ;
115
+ [ 'run' , 'attach' ] . forEach ( cmd => {
116
+ const cmdId = `${ cmdPrefix } .${ cmd } ` ;
117
+ this . push ( commands . registerCommand ( cmdId , this [ `${ cmd } Server` ] , this ) ) ;
118
+ this . push (
119
+ ( function ( ) {
120
+ commands . titles . set ( cmdId , `${ cmd } flutter server` ) ;
121
+ return {
122
+ dispose ( ) {
123
+ commands . titles . delete ( cmdId ) ;
124
+ } ,
125
+ } ;
126
+ } ) ( ) ,
127
+ ) ;
128
+ } ) ;
127
129
this . push ( devServer ) ;
128
130
log ( 'register dev command' ) ;
129
131
}
130
132
131
- private async execute ( ...args : string [ ] ) {
132
- log ( `run dev server, devServer state: ${ devServer . state } ` ) ;
133
- const state = await devServer . start ( args ) ;
133
+ runServer ( ...args : string [ ] ) {
134
+ this . execute ( 'run' , args ) ;
135
+ }
136
+
137
+ attachServer ( ...args : string [ ] ) {
138
+ this . execute ( 'attach' , args ) ;
139
+ }
140
+
141
+ private async execute ( cmd : string , args : string [ ] ) {
142
+ log ( `${ cmd } dev server, devServer state: ${ devServer . state } ` ) ;
143
+ const state = await devServer . start ( [ cmd ] . concat ( args ) ) ;
134
144
if ( state ) {
135
145
devServer . onError ( this . onError ) ;
136
146
devServer . onExit ( this . onExit ) ;
@@ -206,15 +216,15 @@ export class Dev extends Dispose {
206
216
! line . startsWith ( 'Initializing hot reload' ) &&
207
217
! line . startsWith ( 'Performing hot reload' ) &&
208
218
! line . startsWith ( 'Reloaded ' ) &&
209
- ! line . startsWith ( " Flutter run key commands." ) &&
210
- ! line . startsWith ( " r Hot reload. 🔥🔥🔥" ) &&
211
- ! line . startsWith ( " R Hot restart." ) &&
212
- ! line . startsWith ( " h Repeat this help message." ) &&
213
- ! line . startsWith ( " d Detach (terminate \ "flutter run\ " but leave application running)." ) &&
214
- ! line . startsWith ( " c Clear the screen" ) &&
215
- ! line . startsWith ( " q Quit (terminate the application on the device)." ) &&
216
- ! line . startsWith ( " flutter: Another exception was thrown:" ) &&
217
- ! line . startsWith ( " An Observatory debugger and profiler on" ) &&
219
+ ! line . startsWith ( ' Flutter run key commands.' ) &&
220
+ ! line . startsWith ( ' r Hot reload. 🔥🔥🔥' ) &&
221
+ ! line . startsWith ( ' R Hot restart.' ) &&
222
+ ! line . startsWith ( ' h Repeat this help message.' ) &&
223
+ ! line . startsWith ( ' d Detach (terminate "flutter run" but leave application running).' ) &&
224
+ ! line . startsWith ( ' c Clear the screen' ) &&
225
+ ! line . startsWith ( ' q Quit (terminate the application on the device).' ) &&
226
+ ! line . startsWith ( ' flutter: Another exception was thrown:' ) &&
227
+ ! line . startsWith ( ' An Observatory debugger and profiler on' ) &&
218
228
! / ^ f l u t t e r : # \d + + .+ $ / . test ( line )
219
229
) ;
220
230
} ) ;
0 commit comments