@@ -110,9 +110,14 @@ export function main({
110110 command = commands . run ;
111111 }
112112
113+ let warnAboutRunDashDash = false ;
113114 // we using "yarn <script> -abc" or "yarn run <script> -abc", we want -abc to be script options, not yarn options
114115 if ( command === commands . run ) {
115- args . unshift ( '--' ) ;
116+ if ( endArgs . length === 0 ) {
117+ endArgs = [ '--' , ... args . splice ( 1 , args . length ) ] ;
118+ } else {
119+ warnAboutRunDashDash = true ;
120+ }
116121 }
117122
118123 command . setFlags ( commander ) ;
@@ -124,7 +129,7 @@ export function main({
124129 ...getRcArgs ( commandName , args ) ,
125130 ...args ,
126131 ] ) ;
127- commander . args = commander . args . concat ( endArgs ) ;
132+ commander . args = commander . args . concat ( endArgs . slice ( 1 ) ) ;
128133
129134 // we strip cmd
130135 console . assert ( commander . args . length >= 1 ) ;
@@ -176,6 +181,11 @@ export function main({
176181 //
177182 const run = ( ) : Promise < void > => {
178183 invariant ( command , 'missing command' ) ;
184+
185+ if ( warnAboutRunDashDash ) {
186+ reporter . warn ( reporter . lang ( 'dashDashDeprecation' ) ) ;
187+ }
188+
179189 return command . run ( config , reporter , commander , commander . args ) . then ( exitCode => {
180190 if ( outputWrapper ) {
181191 reporter . footer ( false ) ;
@@ -408,7 +418,7 @@ export default function start() {
408418 const doubleDashIndex = process . argv . findIndex ( element => element === '--' ) ;
409419 const startArgs = process . argv . slice ( 0 , 2 ) ;
410420 const args = process . argv . slice ( 2 , doubleDashIndex === - 1 ? process . argv . length : doubleDashIndex ) ;
411- const endArgs = doubleDashIndex === - 1 ? [ ] : process . argv . slice ( doubleDashIndex + 1 , process . argv . length ) ;
421+ const endArgs = doubleDashIndex === - 1 ? [ ] : process . argv . slice ( doubleDashIndex , process . argv . length ) ;
412422
413423 main ( { startArgs, args, endArgs} ) ;
414424}
0 commit comments