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

Commit aac19e2

Browse files
committed
more changes
1 parent 13d933e commit aac19e2

File tree

1 file changed

+21
-38
lines changed

1 file changed

+21
-38
lines changed

CodePush.js

Lines changed: 21 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,27 @@ async function checkForUpdate(deploymentKey = null) {
6464
}
6565
}
6666

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+
6788
function getPromisifiedSdk(requestFetchAdapter, config) {
6889
// Use dynamically overridden AcquisitionSdk during tests.
6990
let sdk = new module.exports.AcquisitionSdk(requestFetchAdapter, config);
@@ -82,44 +103,6 @@ function getPromisifiedSdk(requestFetchAdapter, config) {
82103
return sdk;
83104
}
84105

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-
123106
/* Logs messages to console with the [CodePush] prefix */
124107
function log(message) {
125108
console.log(`[CodePush] ${message}`)

0 commit comments

Comments
 (0)