@@ -18,19 +18,19 @@ export class ProjectTasks {
1818 {
1919 name : 'Upload' ,
2020 args : [ 'run' , '--target' , 'upload' ] ,
21- optionalPortArgs : [ '--upload-port' ] ,
21+ optionalArgs : [ '--upload-port' ] ,
2222 multienv : true ,
2323 } ,
2424 {
2525 name : 'Monitor' ,
2626 args : [ 'device' , 'monitor' ] ,
27- optionalPortArgs : [ '--port' ] ,
27+ optionalArgs : [ '--port' ] ,
2828 multienv : true ,
2929 } ,
3030 {
3131 name : 'Upload and Monitor' ,
3232 args : [ 'run' , '--target' , 'upload' , '--target' , 'monitor' ] ,
33- optionalPortArgs : [ '--upload-port' , '--monitor-port' ] ,
33+ optionalArgs : [ '--upload-port' , '--monitor-port' ] ,
3434 multienv : true ,
3535 } ,
3636 {
@@ -69,7 +69,7 @@ export class ProjectTasks {
6969 {
7070 name : 'Test' ,
7171 args : [ 'test' ] ,
72- optionalPortArgs : [ '--upload-port' , '--test-port' ] ,
72+ optionalArgs : [ '--upload-port' , '--test-port' ] ,
7373 group : 'Advanced' ,
7474 multienv : true ,
7575 } ,
@@ -95,7 +95,7 @@ export class ProjectTasks {
9595 {
9696 name : 'Verbose Upload' ,
9797 args : [ 'run' , '--verbose' , '--target' , 'upload' ] ,
98- optionalPortArgs : [ '--upload-port' ] ,
98+ optionalArgs : [ '--upload-port' ] ,
9999 group : 'Advanced' ,
100100 multienv : true ,
101101 } ,
@@ -121,25 +121,30 @@ export class ProjectTasks {
121121 {
122122 name : 'Remote Upload' ,
123123 args : [ 'remote' , 'run' , '--target' , 'upload' ] ,
124- group : 'Remote Development ' ,
124+ group : 'Remote' ,
125125 multienv : true ,
126126 } ,
127127 {
128128 name : 'Remote Monitor' ,
129129 args : [ 'remote' , 'device' , 'monitor' ] ,
130- group : 'Remote Development ' ,
130+ group : 'Remote' ,
131131 } ,
132132 {
133133 name : 'Remote Devices' ,
134134 args : [ 'remote' , 'device' , 'list' ] ,
135- group : 'Remote Development ' ,
135+ group : 'Remote' ,
136136 } ,
137137 {
138138 name : 'Remote Test' ,
139139 args : [ 'remote' , 'test' ] ,
140- group : 'Remote Development ' ,
140+ group : 'Remote' ,
141141 multienv : true ,
142142 } ,
143+ {
144+ name : 'Upgrade PlatformIO Core' ,
145+ args : [ 'upgrade' ] ,
146+ group : 'Miscellaneous' ,
147+ } ,
143148 ] ;
144149
145150 constructor ( projectDir , ide ) {
@@ -153,18 +158,9 @@ export class ProjectTasks {
153158 const item = new TaskItem ( task . name , task . args . slice ( 0 ) , task . group ) ;
154159 item . description = task . description ;
155160 item . multienv = ! ! task . multienv ;
156- item . optionalPortArgs = task . optionalPortArgs ;
161+ item . optionalArgs = task . optionalArgs ;
157162 return item ;
158163 } ) ;
159- // Miscellaneous tasks
160- result . push (
161- new TaskItem (
162- 'Rebuild IntelliSense Index' ,
163- [ 'project' , 'init' , '--ide' , this . ide ] ,
164- 'Miscellaneous'
165- ) ,
166- new TaskItem ( 'Upgrade PlatformIO Core' , [ 'upgrade' ] , 'Miscellaneous' )
167- ) ;
168164 return result ;
169165 }
170166
@@ -183,9 +179,19 @@ export class ProjectTasks {
183179 ) ;
184180 item . description = task . description ;
185181 item . multienv = true ;
186- item . optionalPortArgs = task . optionalPortArgs ;
182+ item . optionalArgs = task . optionalArgs ;
187183 result . push ( item ) ;
188184 }
185+
186+ // Miscellaneous tasks
187+ const initTask = new TaskItem (
188+ 'Rebuild IntelliSense Index' ,
189+ [ 'project' , 'init' , '--ide' , this . ide , '--environment' , name ] ,
190+ 'Miscellaneous'
191+ ) ;
192+ initTask . multienv = true ;
193+ result . push ( initTask ) ;
194+
189195 // dev-platform targets
190196 try {
191197 for ( const target of await this . fetchEnvTargets ( name ) ) {
@@ -232,7 +238,7 @@ export class TaskItem {
232238 this . group = group ;
233239 this . description = undefined ;
234240 this . multienv = false ;
235- this . optionalPortArgs = undefined ;
241+ this . optionalArgs = undefined ;
236242 }
237243
238244 isBuild ( ) {
@@ -273,11 +279,13 @@ export class TaskItem {
273279
274280 getCoreArgs ( options = { } ) {
275281 const args = this . args . slice ( 0 ) ;
276- if ( this . optionalPortArgs && options . port ) {
277- this . optionalPortArgs . forEach ( ( arg ) => {
278- args . push ( arg ) ;
279- args . push ( options . port ) ;
280- } ) ;
282+ if ( this . optionalArgs && options . port ) {
283+ this . optionalArgs
284+ . filter ( ( arg ) => arg . endsWith ( '-port' ) )
285+ . forEach ( ( arg ) => {
286+ args . push ( arg ) ;
287+ args . push ( options . port ) ;
288+ } ) ;
281289 }
282290 return args ;
283291 }
0 commit comments