File tree Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -15,11 +15,6 @@ const spawnOpts = {
1515 stdin : 'inherit' ,
1616} ;
1717
18- const projectDir = process . cwd ( ) ;
19- const isYarnAvailable =
20- yarn . getYarnVersionIfAvailable ( ) &&
21- yarn . isGlobalCliUsingYarn ( projectDir ) ;
22-
2318/**
2419 * Execute npm or yarn command
2520 *
@@ -30,6 +25,11 @@ const isYarnAvailable =
3025function callYarnOrNpm ( yarnCommand , npmCommand ) {
3126 let command ;
3227
28+ const projectDir = process . cwd ( ) ;
29+ const isYarnAvailable =
30+ yarn . getYarnVersionIfAvailable ( ) &&
31+ yarn . isGlobalCliUsingYarn ( projectDir ) ;
32+
3333 if ( isYarnAvailable ) {
3434 command = yarnCommand ;
3535 } else {
Original file line number Diff line number Diff line change @@ -21,11 +21,9 @@ function getYarnVersionIfAvailable() {
2121 let yarnVersion ;
2222 try {
2323 // execSync returns a Buffer -> convert to string
24- if ( process . platform . startsWith ( 'win' ) ) {
25- yarnVersion = ( execSync ( 'yarn --version' ) . toString ( ) || '' ) . trim ( ) ;
26- } else {
27- yarnVersion = ( execSync ( 'yarn --version 2>/dev/null' ) . toString ( ) || '' ) . trim ( ) ;
28- }
24+ yarnVersion = ( execSync ( 'yarn --version' , {
25+ stdio : [ 0 , 'pipe' , 'ignore' , ]
26+ } ) . toString ( ) || '' ) . trim ( ) ;
2927 } catch ( error ) {
3028 return null ;
3129 }
You can’t perform that action at this time.
0 commit comments