@@ -9,8 +9,6 @@ var NativeCodePush = require('react-native').NativeModules.CodePush;
9
9
var requestFetchAdapter = require ( "./request-fetch-adapter.js" ) ;
10
10
var semver = require ( 'semver' ) ;
11
11
var Sdk = require ( "code-push/script/acquisition-sdk" ) . AcquisitionManager ;
12
- var sdk ;
13
- var config ;
14
12
15
13
// This function is only used for tests. Replaces the default SDK, configuration and native bridge
16
14
function setUpTestDependencies ( testSdk , testConfiguration , testNativeBridge ) {
@@ -19,29 +17,35 @@ function setUpTestDependencies(testSdk, testConfiguration, testNativeBridge){
19
17
if ( testNativeBridge ) NativeCodePush = testNativeBridge ;
20
18
}
21
19
22
- function getConfiguration ( ) {
23
- if ( config ) {
24
- return Promise . resolve ( config ) ;
25
- } else {
26
- return NativeCodePush . getConfiguration ( )
27
- . then ( ( configuration ) => {
28
- if ( ! config ) config = configuration ;
29
- return config ;
30
- } ) ;
20
+ var getConfiguration = ( ( ) => {
21
+ var config ;
22
+ return function getConfiguration ( ) {
23
+ if ( config ) {
24
+ return Promise . resolve ( config ) ;
25
+ } else {
26
+ return NativeCodePush . getConfiguration ( )
27
+ . then ( ( configuration ) => {
28
+ if ( ! config ) config = configuration ;
29
+ return config ;
30
+ } ) ;
31
+ }
31
32
}
32
- }
33
+ } ) ( ) ;
33
34
34
- function getSdk ( ) {
35
- if ( sdk ) {
36
- return Promise . resolve ( sdk ) ;
37
- } else {
38
- return getConfiguration ( )
39
- . then ( ( configuration ) => {
40
- sdk = new Sdk ( requestFetchAdapter , configuration ) ;
41
- return sdk ;
42
- } ) ;
35
+ var getSdk = ( ( ) => {
36
+ var sdk ;
37
+ return function getSdk ( ) {
38
+ if ( sdk ) {
39
+ return Promise . resolve ( sdk ) ;
40
+ } else {
41
+ return getConfiguration ( )
42
+ . then ( ( configuration ) => {
43
+ sdk = new Sdk ( requestFetchAdapter , configuration ) ;
44
+ return sdk ;
45
+ } ) ;
46
+ }
43
47
}
44
- }
48
+ } ) ( ) ;
45
49
46
50
function checkForUpdate ( callback ) {
47
51
getConfiguration ( ) . then ( function ( configuration ) {
0 commit comments