@@ -90,27 +90,34 @@ function createCodePushApp(name, os) {
9090 owner = app . owner . name ;
9191 console . log ( `App "${ name } " has been created \n` ) ;
9292 } catch ( e ) {
93- console . log ( " Error: " , e ) ;
94- console . log ( `Please check that you haven't application with " ${ name } " name on portal` ) ;
93+ console . error ( ` Error: Unable to create CodePush app. Please check that you haven't application with " ${ name } " name on portal.` , ) ;
94+ console . error ( "Error: " , e . toString ( ) ) ;
9595 }
9696 execCommand ( `appcenter codepush deployment add -a ${ owner } /${ name } Staging` ) ;
9797 } catch ( e ) {
98- console . log ( "Error" , e ) ;
98+ console . error ( "Error" , e . toString ( ) ) ;
9999 }
100- const deploymentKeysResult = execCommand ( `appcenter codepush deployment list -a ${ owner } /${ name } -k --output json` ) ;
101- const deploymentKeys = JSON . parse ( deploymentKeysResult ) ;
102- const stagingDeploymentKey = deploymentKeys [ 0 ] [ 1 ] ;
103- console . log ( `Deployment key for ${ os } : ${ stagingDeploymentKey } ` ) ;
104- console . log ( `Use "appcenter codepush release-react ${ owner } /${ name } " command to release updates for ${ os } \n` ) ;
105-
106- switch ( os ) {
107- case 'Android' :
108- androidStagingDeploymentKey = stagingDeploymentKey ;
109- break ;
110- case 'iOS' :
111- iosStagingDeploymentKey = stagingDeploymentKey ;
112- break ;
100+
101+ try {
102+ const deploymentKeysResult = execCommand ( `appcenter codepush deployment list -a ${ owner } /${ name } -k --output json` ) ;
103+ const deploymentKeys = JSON . parse ( deploymentKeysResult ) ;
104+ const stagingDeploymentKey = deploymentKeys [ 0 ] [ 1 ] ;
105+ console . log ( `Deployment key for ${ os } : ${ stagingDeploymentKey } ` ) ;
106+ console . log ( `Use "appcenter codepush release-react ${ owner } /${ name } " command to release updates for ${ os } \n` ) ;
107+
108+ switch ( os ) {
109+ case 'Android' :
110+ androidStagingDeploymentKey = stagingDeploymentKey ;
111+ break ;
112+ case 'iOS' :
113+ iosStagingDeploymentKey = stagingDeploymentKey ;
114+ break ;
115+ }
116+ } catch ( e ) {
117+ console . error ( "Error: Unable to load deployment keys" ) ;
118+ console . error ( "Error: " , e . toString ( ) ) ;
113119 }
120+
114121}
115122
116123function generatePlainReactNativeApp ( appName , reactNativeVersion ) {
@@ -165,12 +172,12 @@ function setupAssets() {
165172 fs . writeFileSync ( 'index.android.js' , fs . readFileSync ( '../CodePushDemoApp-pre0.49/index.android.js' ) ) ;
166173 fileToEdit = 'demo.js'
167174 } else {
168- fs . writeFileSync ( 'index.js' , fs . readFileSync ( '.. /CodePushDemoApp/index.js') ) ;
169- fs . writeFileSync ( 'App.js' , fs . readFileSync ( '.. /CodePushDemoApp/App.js') ) ;
175+ fs . writeFileSync ( 'index.js' , fs . readFileSync ( __dirname + ' /CodePushDemoApp/index.js') ) ;
176+ fs . writeFileSync ( 'App.js' , fs . readFileSync ( __dirname + ' /CodePushDemoApp/App.js') ) ;
170177 fileToEdit = 'index.js'
171178 }
172179
173- copyRecursiveSync ( '.. /CodePushDemoApp/images', './images' ) ;
180+ copyRecursiveSync ( __dirname + ' /CodePushDemoApp/images', './images' ) ;
174181
175182 fs . readFile ( fileToEdit , 'utf8' , function ( err , data ) {
176183 if ( err ) {
0 commit comments