From d9e307659f4faccd7629c31a4fb02716aa668674 Mon Sep 17 00:00:00 2001 From: sunnylqm Date: Thu, 8 Apr 2021 23:46:14 +0800 Subject: [PATCH] export cInfo --- .gitignore | 1 + lib/index.js | 42 +++++++++++++++++++++++++----------------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 53e7a79..a9a2055 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,4 @@ npm-debug.log Example/**/update.json yarn-error.log +Example/testHotUpdate/.pushy diff --git a/lib/index.js b/lib/index.js index 26d341f..ac1f606 100644 --- a/lib/index.js +++ b/lib/index.js @@ -67,6 +67,13 @@ There is available update: } */ +export const cInfo = { + pushy: require('../package.json').version, + rn: RNVersion, + os: Platform.OS + ' ' + Platform.Version, + uuid, +}; + function assertRelease() { if (__DEV__) { throw new Error('react-native-update can only run on RELEASE version.'); @@ -98,12 +105,7 @@ export async function checkUpdate(APPKEY, isRetry) { packageVersion, hash: currentVersion, buildTime, - cInfo: { - pushy: require('../package.json').version, - rn: RNVersion, - os: Platform.OS + ' ' + Platform.Version, - uuid, - }, + cInfo, }), }); } catch (e) { @@ -147,11 +149,14 @@ export async function downloadUpdate(options, eventListeners) { if (eventListeners) { if (eventListeners.onDownloadProgress) { const downloadCallback = eventListeners.onDownloadProgress; - progressHandler = eventEmitter.addListener('RCTPushyDownloadProgress', (progressData) => { - if (progressData.hash === options.hash) { - downloadCallback(progressData); - } - }); + progressHandler = eventEmitter.addListener( + 'RCTPushyDownloadProgress', + (progressData) => { + if (progressData.hash === options.hash) { + downloadCallback(progressData); + } + }, + ); } } if (options.diffUrl) { @@ -167,7 +172,7 @@ export async function downloadUpdate(options, eventListeners) { updateUrl: options.pdiffUrl, hash: options.hash, }); - }else if (options.hdiffUrl) { + } else if (options.hdiffUrl) { logger('downloading hdiff'); await Pushy.downloadHPatchFromPpk({ updateUrl: options.hdiffUrl, @@ -208,11 +213,14 @@ export async function downloadAndInstallApk({ url, onDownloadProgress }) { let hash = Date.now().toString(); let progressHandler; if (onDownloadProgress) { - progressHandler = eventEmitter.addListener('RCTPushyDownloadProgress', (progressData) => { - if (progressData.hash === hash) { - onDownloadProgress(progressData); - } - }); + progressHandler = eventEmitter.addListener( + 'RCTPushyDownloadProgress', + (progressData) => { + if (progressData.hash === hash) { + onDownloadProgress(progressData); + } + }, + ); } await Pushy.downloadAndInstallApk({ url,