@@ -37,7 +37,6 @@ const execSync = require("child_process").execSync;
3737const spawn = require ( "cross-spawn" ) ;
3838const dns = require ( "dns" ) ;
3939const url = require ( "url" ) ;
40- // const envinfo = require("envinfo");
4140
4241const packageJson = require ( "./package.json" ) ;
4342const _wpThemeVersion = packageJson . version ;
@@ -52,8 +51,7 @@ const _getScriptsPath = function() {
5251const scriptsFromNpm = function ( ) {
5352//console.log("SCRIPTS FROM NPM");
5453return {
55- path :`@devloco/react-scripts-wptheme@${ _reactScriptsWpThemeVersion } ` ,
56- callback :function ( ) { }
54+ path :`@devloco/react-scripts-wptheme@${ _reactScriptsWpThemeVersion } `
5755} ;
5856} ;
5957
@@ -210,24 +208,9 @@ function createWpTheme(root, appName, version, verbose, originalDirectory, templ
210208}
211209
212210let 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 ) ;
214212} )
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 ) ;
231214}
232215
233216function createReactApp ( createWpThemeReactRoot , appName , version , verbose , originalDirectory , template , useYarn , usePnp ) {
@@ -271,12 +254,10 @@ function createReactApp(createWpThemeReactRoot, appName, version, verbose, origi
271254return ;
272255}
273256
274- scriptsPath . callback ( ) ;
257+ scriptsPath && scriptsPath . callback && scriptsPath . callback ( ) ;
275258resolve ( ) ;
276259} ) ;
277- } ) . catch ( ( code ) => {
278- reject ( code ) ;
279- } ) ;
260+ } ) . catch ( catchHandler ) ;
280261}
281262
282263function checkAppName ( appName ) {
@@ -339,3 +320,21 @@ function checkIfOnline(useYarn) {
339320} ) ;
340321} ) ;
341322}
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+ }