@@ -37,7 +37,6 @@ const execSync = require("child_process").execSync;
37
37
const spawn = require ( "cross-spawn" ) ;
38
38
const dns = require ( "dns" ) ;
39
39
const url = require ( "url" ) ;
40
- // const envinfo = require("envinfo");
41
40
42
41
const packageJson = require ( "./package.json" ) ;
43
42
const _wpThemeVersion = packageJson . version ;
@@ -52,8 +51,7 @@ const _getScriptsPath = function() {
52
51
const scriptsFromNpm = function ( ) {
53
52
//console.log("SCRIPTS FROM NPM");
54
53
return {
55
- path : `@devloco/react-scripts-wptheme@${ _reactScriptsWpThemeVersion } ` ,
56
- callback : function ( ) { }
54
+ path : `@devloco/react-scripts-wptheme@${ _reactScriptsWpThemeVersion } `
57
55
} ;
58
56
} ;
59
57
@@ -210,24 +208,9 @@ function createWpTheme(root, appName, version, verbose, originalDirectory, templ
210
208
}
211
209
212
210
let createWpThemeReactRoot = "react-src" ;
213
- createReactApp ( createWpThemeReactRoot , appName , version , verbose , originalDirectory , template , useYarn , usePnp ) ;
211
+ createReactApp ( createWpThemeReactRoot , appName , version , verbose , originalDirectory , template , useYarn , usePnp ) . catch ( catchHandler ) ;
214
212
} )
215
- . catch ( ( reason ) => {
216
- console . log ( ) ;
217
- console . log ( "Aborting installation." ) ;
218
-
219
- if ( reason . command ) {
220
- console . log ( ` ${ chalk . cyan ( reason . command ) } has failed.` ) ;
221
- } else {
222
- console . log ( chalk . red ( "Unexpected error." ) , reason ) ;
223
- console . log ( "Please report it as a bug here:" ) ;
224
- console . log ( "https://github.com/devloco/create-react-wptheme/issues" ) ;
225
- }
226
-
227
- console . log ( ) ;
228
- console . log ( "Done." ) ;
229
- process . exit ( 1 ) ;
230
- } ) ;
213
+ . catch ( catchHandler ) ;
231
214
}
232
215
233
216
function createReactApp ( createWpThemeReactRoot , appName , version , verbose , originalDirectory , template , useYarn , usePnp ) {
@@ -271,12 +254,10 @@ function createReactApp(createWpThemeReactRoot, appName, version, verbose, origi
271
254
return ;
272
255
}
273
256
274
- scriptsPath . callback ( ) ;
257
+ scriptsPath && scriptsPath . callback && scriptsPath . callback ( ) ;
275
258
resolve ( ) ;
276
259
} ) ;
277
- } ) . catch ( ( code ) => {
278
- reject ( code ) ;
279
- } ) ;
260
+ } ) . catch ( catchHandler ) ;
280
261
}
281
262
282
263
function checkAppName ( appName ) {
@@ -339,3 +320,21 @@ function checkIfOnline(useYarn) {
339
320
} ) ;
340
321
} ) ;
341
322
}
323
+
324
+ function catchHandler ( reason ) {
325
+ console . log ( ) ;
326
+ console . log ( chalk . red ( "Aborting installation." ) ) ;
327
+
328
+ if ( reason && reason . command ) {
329
+ console . log ( ` ${ chalk . cyan ( reason . command ) } has failed.` ) ;
330
+ } else {
331
+ console . log ( chalk . red ( "Unexpected error." ) , reason ) ;
332
+ console . log ( ) ;
333
+ console . log ( "Please report it as a bug here:" ) ;
334
+ console . log ( "https://github.com/devloco/create-react-wptheme/issues" ) ;
335
+ }
336
+
337
+ console . log ( ) ;
338
+ console . log ( "Done." ) ;
339
+ process . exit ( 1 ) ;
340
+ }
0 commit comments