@@ -69,6 +69,23 @@ const scriptsFromNpm = function() {
69
69
} ;
70
70
71
71
const scriptsFromGit = function ( ) {
72
+ const deleteFolderRecursive = ( path ) => {
73
+ if ( fs . existsSync ( path ) ) {
74
+ fs . readdirSync ( path ) . forEach ( function ( file ) {
75
+ let curPath = path + "/" + file ;
76
+ if ( fs . statSync ( curPath ) . isDirectory ( ) ) {
77
+ // recurse
78
+ deleteFolderRecursive ( curPath ) ;
79
+ } else {
80
+ // delete file
81
+ fs . unlinkSync ( curPath ) ;
82
+ }
83
+ } ) ;
84
+
85
+ fs . rmdirSync ( path ) ;
86
+ }
87
+ }
88
+
72
89
const tempFolderName = "temp" ;
73
90
fs . ensureDirSync ( tempFolderName ) ;
74
91
process . chdir ( tempFolderName ) ;
@@ -197,17 +214,8 @@ function createApp(
197
214
198
215
const useYarn = useNpm ? false : shouldUseYarn ( ) ;
199
216
const originalDirectory = process . cwd ( ) ;
200
- process . chdir ( root ) ;
201
- if ( ! useYarn && ! checkThatNpmCanReadCwd ( ) ) {
202
- process . exit ( 1 ) ;
203
- }
204
217
205
- if ( useYarn ) {
206
- fs . copySync (
207
- require . resolve ( './yarn.lock.cached' ) ,
208
- path . join ( root , 'yarn.lock' )
209
- ) ;
210
- }
218
+ process . chdir ( appName ) ; // change into the newly created folder, then run create-react-app.
211
219
212
220
createWpTheme (
213
221
root ,
@@ -347,6 +355,7 @@ function checkAppName(appName) {
347
355
`"${ appName } "`
348
356
) } because of npm naming restrictions:`
349
357
) ;
358
+
350
359
printValidationResults ( validationResult . errors ) ;
351
360
printValidationResults ( validationResult . warnings ) ;
352
361
process . exit ( 1 ) ;
@@ -468,20 +477,3 @@ function checkIfOnline(useYarn) {
468
477
} ) ;
469
478
} ) ;
470
479
}
471
-
472
- function deleteFolderRecursive ( path ) {
473
- if ( fs . existsSync ( path ) ) {
474
- fs . readdirSync ( path ) . forEach ( function ( file ) {
475
- let curPath = path + "/" + file ;
476
- if ( fs . statSync ( curPath ) . isDirectory ( ) ) {
477
- // recurse
478
- deleteFolderRecursive ( curPath ) ;
479
- } else {
480
- // delete file
481
- fs . unlinkSync ( curPath ) ;
482
- }
483
- } ) ;
484
-
485
- fs . rmdirSync ( path ) ;
486
- }
487
- }
0 commit comments