@@ -73,6 +73,58 @@ test('--mutex network', async () => {
7373 ] ) ;
7474} ) ;
7575
76+ // Windows doesn't have the "echo" utility
77+ // Since this feature isn't platform-specific, running them on OSX and Linux only should be fine
78+ if ( process . platform !== 'win32' ) {
79+ test ( 'yarn run <script> --opt' , async ( ) => {
80+ const cwd = await makeTemp ( ) ;
81+
82+ await fs . writeFile (
83+ path . join ( cwd , 'package.json' ) ,
84+ JSON . stringify ( {
85+ scripts : { echo : 'echo' } ,
86+ } ) ,
87+ ) ;
88+
89+ const command = path . resolve ( __dirname , '../bin/yarn' ) ;
90+ const options = { cwd, env : { YARN_SILENT : 1 } } ;
91+
92+ const { stderr : stderr , stdout : stdout } = execa ( command , [ 'run' , 'echo' , '--opt' ] , options ) ;
93+
94+ const stdoutPromise = misc . consumeStream ( stdout ) ;
95+ const stderrPromise = misc . consumeStream ( stderr ) ;
96+
97+ const [ stdoutOutput , stderrOutput ] = await Promise . all ( [ stdoutPromise , stderrPromise ] ) ;
98+
99+ expect ( stdoutOutput . toString ( ) . trim ( ) ) . toEqual ( '--opt' ) ;
100+ expect ( stderrOutput . toString ( ) ) . not . toMatch ( / U s i n g - - t o p a s s a r g u m e n t s t o y o u r s c r i p t s i s n ' t r e q u i r e d a n y m o r e / ) ;
101+ } ) ;
102+
103+ test ( 'yarn run <script> -- --opt' , async ( ) => {
104+ const cwd = await makeTemp ( ) ;
105+
106+ await fs . writeFile (
107+ path . join ( cwd , 'package.json' ) ,
108+ JSON . stringify ( {
109+ scripts : { echo : 'echo' } ,
110+ } ) ,
111+ ) ;
112+
113+ const command = path . resolve ( __dirname , '../bin/yarn' ) ;
114+ const options = { cwd, env : { YARN_SILENT : 1 } } ;
115+
116+ const { stderr : stderr , stdout : stdout } = execa ( command , [ 'run' , 'echo' , '--' , '--opt' ] , options ) ;
117+
118+ const stdoutPromise = misc . consumeStream ( stdout ) ;
119+ const stderrPromise = misc . consumeStream ( stderr ) ;
120+
121+ const [ stdoutOutput , stderrOutput ] = await Promise . all ( [ stdoutPromise , stderrPromise ] ) ;
122+
123+ expect ( stdoutOutput . toString ( ) . trim ( ) ) . toEqual ( '--opt' ) ;
124+ expect ( stderrOutput . toString ( ) ) . toMatch ( / U s i n g - - t o p a s s a r g u m e n t s t o y o u r s c r i p t s i s n ' t r e q u i r e d a n y m o r e / ) ;
125+ } ) ;
126+ }
127+
76128test ( 'cache folder fallback' , async ( ) => {
77129 const cwd = await makeTemp ( ) ;
78130 const cacheFolder = path . join ( cwd , '.cache' ) ;
0 commit comments