1
1
const execa = require ( 'execa' )
2
2
const terminate = require ( 'terminate' )
3
+ const chalk = require ( 'chalk' )
3
4
// Subs
4
5
const channels = require ( '../channels' )
5
6
// Connectors
@@ -10,7 +11,6 @@ const plugins = require('./plugins')
10
11
const prompts = require ( './prompts' )
11
12
const views = require ( './views' )
12
13
// Utils
13
- const { getCommand } = require ( '../utils/command' )
14
14
const { log } = require ( '../utils/logger' )
15
15
const { notify } = require ( '../utils/notification' )
16
16
@@ -62,7 +62,7 @@ function list (context) {
62
62
index : list . findIndex ( t => t . id === id ) ,
63
63
prompts : [ ] ,
64
64
views : [ ] ,
65
- fullCommand : true ,
65
+ uiOnly : true ,
66
66
...task
67
67
}
68
68
}
@@ -220,8 +220,8 @@ async function run (id, context) {
220
220
221
221
// Answers
222
222
const answers = prompts . getAnswers ( )
223
- let args = task . fullCommand ? [ ] : [ 'run' , task . name ]
224
- let command = task . fullCommand ? task . command : getCommand ( )
223
+ let args = [ ]
224
+ let command = task . command
225
225
226
226
// Process command containing args
227
227
if ( command . indexOf ( ' ' ) ) {
@@ -248,6 +248,25 @@ async function run (id, context) {
248
248
} )
249
249
}
250
250
251
+ // Deduplicate arguments
252
+ const dedupedArgs = [ ]
253
+ for ( let i = args . length - 1 ; i >= 0 ; i -- ) {
254
+ const arg = args [ i ]
255
+ if ( arg . indexOf ( '--' ) === 0 ) {
256
+ if ( dedupedArgs . indexOf ( arg ) === - 1 ) {
257
+ dedupedArgs . push ( arg )
258
+ } else {
259
+ const value = args [ i + 1 ]
260
+ if ( value && value . indexOf ( '--' ) !== 0 ) {
261
+ dedupedArgs . pop ( )
262
+ }
263
+ }
264
+ } else {
265
+ dedupedArgs . push ( arg )
266
+ }
267
+ }
268
+ args = dedupedArgs . reverse ( )
269
+
251
270
if ( command === 'npm' ) {
252
271
args . splice ( 0 , 0 , '--' )
253
272
}
@@ -263,13 +282,11 @@ async function run (id, context) {
263
282
type : 'info'
264
283
} , context )
265
284
266
- if ( task . fullCommand ) {
267
- addLog ( {
268
- taskId : task . id ,
269
- type : 'stdout' ,
270
- text : `$ ${ command } ${ args . join ( ' ' ) } `
271
- } , context )
272
- }
285
+ addLog ( {
286
+ taskId : task . id ,
287
+ type : 'stdout' ,
288
+ text : chalk . grey ( `$ ${ command } ${ args . join ( ' ' ) } ` )
289
+ } , context )
273
290
274
291
process . env . VUE_CLI_CONTEXT = cwd . get ( )
275
292
0 commit comments