@@ -14,6 +14,7 @@ const projects = require('./projects')
14
14
const { log } = require ( '../util/logger' )
15
15
const { notify } = require ( '../util/notification' )
16
16
const { terminate } = require ( '../util/terminate' )
17
+ const { parseArgs } = require ( '../util/parse-args' )
17
18
18
19
const MAX_LOGS = 2000
19
20
const VIEW_ID = 'vue-project-tasks'
@@ -237,22 +238,21 @@ async function run (id, context) {
237
238
238
239
// Answers
239
240
const answers = prompts . getAnswers ( )
240
- let args = [ ]
241
- let command = task . command
242
-
243
- // Process command containing args
244
- if ( command . indexOf ( ' ' ) ) {
245
- const parts = command . split ( / \s + / )
246
- command = parts . shift ( )
247
- args = parts
248
- }
241
+ let [ command , ...args ] = parseArgs ( task . command )
249
242
250
243
// Output colors
251
244
// See: https://www.npmjs.com/package/supports-color
252
245
process . env . FORCE_COLOR = 1
253
246
254
247
// Plugin API
255
248
if ( task . onBeforeRun ) {
249
+ if ( ! answers . $_overrideArgs ) {
250
+ const origPush = args . push . bind ( args )
251
+ args . push = ( ...items ) => {
252
+ if ( items . length && args . indexOf ( items [ 0 ] ) !== - 1 ) return items . length
253
+ return origPush ( ...items )
254
+ }
255
+ }
256
256
await task . onBeforeRun ( {
257
257
answers,
258
258
args
@@ -581,6 +581,15 @@ async function restoreParameters ({ id }, context) {
581
581
const task = findOne ( id , context )
582
582
if ( task ) {
583
583
await prompts . reset ( )
584
+ if ( task . prompts . length ) {
585
+ prompts . add ( {
586
+ name : '$_overrideArgs' ,
587
+ type : 'confirm' ,
588
+ default : false ,
589
+ message : 'org.vue.views.project-task-details.override-args.message' ,
590
+ description : 'org.vue.views.project-task-details.override-args.description'
591
+ } )
592
+ }
584
593
task . prompts . forEach ( prompts . add )
585
594
const data = getSavedData ( id , context )
586
595
if ( data ) {
0 commit comments