@@ -69,6 +69,23 @@ const scriptsFromNpm = function() {
6969} ;
7070
7171const 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+
7289 const tempFolderName = "temp" ;
7390 fs . ensureDirSync ( tempFolderName ) ;
7491 process . chdir ( tempFolderName ) ;
@@ -197,17 +214,8 @@ function createApp(
197214
198215 const useYarn = useNpm ? false : shouldUseYarn ( ) ;
199216 const originalDirectory = process . cwd ( ) ;
200- process . chdir ( root ) ;
201- if ( ! useYarn && ! checkThatNpmCanReadCwd ( ) ) {
202- process . exit ( 1 ) ;
203- }
204217
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.
211219
212220 createWpTheme (
213221 root ,
@@ -347,6 +355,7 @@ function checkAppName(appName) {
347355 `"${ appName } "`
348356 ) } because of npm naming restrictions:`
349357 ) ;
358+
350359 printValidationResults ( validationResult . errors ) ;
351360 printValidationResults ( validationResult . warnings ) ;
352361 process . exit ( 1 ) ;
@@ -468,20 +477,3 @@ function checkIfOnline(useYarn) {
468477 } ) ;
469478 } ) ;
470479}
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