@@ -64,6 +64,27 @@ async function checkForUpdate(deploymentKey = null) {
64
64
}
65
65
}
66
66
67
+ let getConfiguration = ( ( ) => {
68
+ let config ;
69
+ return async function getConfiguration ( ) {
70
+ if ( config ) {
71
+ return config ;
72
+ } else if ( testConfig ) {
73
+ return testConfig ;
74
+ } else {
75
+ config = await NativeCodePush . getConfiguration ( ) ;
76
+ return config ;
77
+ }
78
+ }
79
+ } ) ( ) ;
80
+
81
+ async function getCurrentPackage ( ) {
82
+ let localPackage = await NativeCodePush . getCurrentPackage ( ) ;
83
+ localPackage . failedInstall = await NativeCodePush . isFailedUpdate ( localPackage . packageHash ) ;
84
+ localPackage . isFirstRun = await NativeCodePush . isFirstRun ( localPackage . packageHash ) ;
85
+ return localPackage ;
86
+ }
87
+
67
88
function getPromisifiedSdk ( requestFetchAdapter , config ) {
68
89
// Use dynamically overridden AcquisitionSdk during tests.
69
90
let sdk = new module . exports . AcquisitionSdk ( requestFetchAdapter , config ) ;
@@ -82,44 +103,6 @@ function getPromisifiedSdk(requestFetchAdapter, config) {
82
103
return sdk ;
83
104
}
84
105
85
- let getConfiguration = ( ( ) => {
86
- let config ;
87
- return ( ) => {
88
- if ( config ) {
89
- return Promise . resolve ( config ) ;
90
- } else if ( testConfig ) {
91
- return Promise . resolve ( testConfig ) ;
92
- } else {
93
- return NativeCodePush . getConfiguration ( )
94
- . then ( ( configuration ) => {
95
- if ( ! config ) config = configuration ;
96
- return config ;
97
- } ) ;
98
- }
99
- } ;
100
- } ) ( ) ;
101
-
102
- function getCurrentPackage ( ) {
103
- return new Promise ( ( resolve , reject ) => {
104
- var localPackage ;
105
- NativeCodePush . getCurrentPackage ( )
106
- . then ( ( currentPackage ) => {
107
- localPackage = currentPackage ;
108
- return NativeCodePush . isFailedUpdate ( currentPackage . packageHash ) ;
109
- } )
110
- . then ( ( failedUpdate ) => {
111
- localPackage . failedInstall = failedUpdate ;
112
- return NativeCodePush . isFirstRun ( localPackage . packageHash ) ;
113
- } )
114
- . then ( ( isFirstRun ) => {
115
- localPackage . isFirstRun = isFirstRun ;
116
- resolve ( localPackage ) ;
117
- } )
118
- . catch ( reject )
119
- . done ( ) ;
120
- } ) ;
121
- }
122
-
123
106
/* Logs messages to console with the [CodePush] prefix */
124
107
function log ( message ) {
125
108
console . log ( `[CodePush] ${ message } ` )
0 commit comments