@@ -237,21 +237,35 @@ inquirer
237
237
}
238
238
239
239
if ( fs . existsSync ( paths . yarnLockFile ) ) {
240
- // TODO: this is disabled for three reasons.
241
- //
242
- // 1. It produces garbage warnings on Windows on some systems:
243
- // https://github.com/facebookincubator/create-react-app/issues/2030
244
- //
245
- // 2. For the above reason, it breaks Windows CI:
246
- // https://github.com/facebookincubator/create-react-app/issues/2624
247
- //
248
- // 3. It is wrong anyway: re-running yarn will respect the lockfile
249
- // rather than package.json we just updated. Instead we should have
250
- // updated the lockfile. So we might as well not do it while it's broken.
251
- // https://github.com/facebookincubator/create-react-app/issues/2627
252
- //
253
- // console.log(cyan('Running yarn...'));
254
- // spawnSync('yarnpkg', [], { stdio: 'inherit' });
240
+ const windowsCmdFilePath = path . join (
241
+ appPath ,
242
+ 'node_modules' ,
243
+ '.bin' ,
244
+ 'react-scripts.cmd'
245
+ ) ;
246
+ let windowsCmdFileContent ;
247
+ if ( process . platform === 'win32' ) {
248
+ // https://github.com/facebookincubator/create-react-app/pull/3806#issuecomment-357781035
249
+ // Yarn is diligent about cleaning up after itself, but this causes the react-scripts.cmd file
250
+ // to be deleted while it is running. This trips Windows up after the eject completes.
251
+ // We'll read the batch file and later "write it back" to match npm behavior.
252
+ try {
253
+ windowsCmdFileContent = fs . readFileSync ( windowsCmdFilePath ) ;
254
+ } catch ( err ) {
255
+ // If this fails we're not worse off than if we didn't try to fix it.
256
+ }
257
+ }
258
+
259
+ console . log ( cyan ( 'Running yarn...' ) ) ;
260
+ spawnSync ( 'yarnpkg' , [ '--cwd' , process . cwd ( ) ] , { stdio : 'inherit' } ) ;
261
+
262
+ if ( windowsCmdFileContent && ! fs . existsSync ( windowsCmdFilePath ) ) {
263
+ try {
264
+ fs . writeFileSync ( windowsCmdFilePath , windowsCmdFileContent ) ;
265
+ } catch ( err ) {
266
+ // If this fails we're not worse off than if we didn't try to fix it.
267
+ }
268
+ }
255
269
} else {
256
270
console . log ( cyan ( 'Running npm install...' ) ) ;
257
271
spawnSync ( 'npm' , [ 'install' , '--loglevel' , 'error' ] , {
0 commit comments