Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit f99a6ce

Browse files
committed
Merge pull request #68 from Microsoft/delpoyment_key_cachde
Fixing caching issue with specifying a deployment key
2 parents f0f3737 + 92e4f3d commit f99a6ce

File tree

1 file changed

+14
-27
lines changed

1 file changed

+14
-27
lines changed

CodePush.ios.js

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,20 @@ var requestFetchAdapter = require("./request-fetch-adapter.js");
77
var Sdk = require("code-push/script/acquisition-sdk").AcquisitionManager;
88

99
function checkForUpdate(deploymentKey = null) {
10-
var config;
11-
var sdk;
10+
var config, sdk;
1211

1312
return getConfiguration()
14-
.then((configResult) => {
15-
config = configResult;
16-
13+
.then((configResult) => {
1714
// If a deployment key was explicitly provided,
1815
// then let's override the one we retrieved
1916
// from the native-side of the app.
2017
if (deploymentKey) {
21-
config.deploymentKey = deploymentKey;
18+
config = Object.assign({}, configResult, { deploymentKey });
19+
} else {
20+
config = configResult;
2221
}
2322

24-
return getSdk();
25-
})
26-
.then((sdkResult) => {
27-
sdk = sdkResult;
23+
sdk = getSDK(config);
2824
return getCurrentPackage();
2925
})
3026
.then((localPackage) => {
@@ -76,23 +72,6 @@ var getConfiguration = (() => {
7672
}
7773
})();
7874

79-
var getSdk = (() => {
80-
var sdk;
81-
return function getSdk() {
82-
if (sdk) {
83-
return Promise.resolve(sdk);
84-
} else if (testSdk) {
85-
return Promise.resolve(testSdk);
86-
} else {
87-
return getConfiguration()
88-
.then((configuration) => {
89-
sdk = new Sdk(requestFetchAdapter, configuration);
90-
return sdk;
91-
});
92-
}
93-
}
94-
})();
95-
9675
function getCurrentPackage() {
9776
return new Promise((resolve, reject) => {
9877
var localPackage;
@@ -114,6 +93,14 @@ function getCurrentPackage() {
11493
});
11594
}
11695

96+
function getSDK(config) {
97+
if (testSdk) {
98+
return testSdk;
99+
} else {
100+
return new Sdk(requestFetchAdapter, config);
101+
}
102+
}
103+
117104
/* Logs messages to console with the [CodePush] prefix */
118105
function log(message) {
119106
console.log(`[CodePush] ${message}`)

0 commit comments

Comments
 (0)