Skip to content

return always a NeedUpdateResult. #243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,17 +201,14 @@ VersionCheck.needUpdate({
fetchOptions | _object_ | isomorphic-fetch options (https://github.github.io/fetch/)
ignoreErrors | _boolean_ | true

- <a name="needUpdate" href="#needUpdate">#</a>**`needUpdate([option: Object])`** _(Promise<result: Object>)_ - Returns an object contains with boolean value whether update needed, current version and latest version. Current and the latest app versions are first split by delimiter, and check each split numbers into depth.
- <a name="needUpdate" href="#needUpdate">#</a>**`needUpdate([option: NeedUpdateOption])`** _(Promise<result: NeedUpdateResult>)_ - Returns an object contains with boolean value whether update needed, current version and latest version. Current and the latest app versions are first split by delimiter, and check each split numbers into depth.
- Option

Field | Type | Default
--- | --- | ---
currentVersion | _string_ | app's current version from [getCurrentVersion()](#getCurrentVersion)
latestVersion | _string_ | app's latest version from [getLatestVersion()](#getLatestVersion)
depth | _number_ | ```Infinity```
forceUpdate | _boolean_ | ```false```
provider | _string_ or _function_ | provider name or function that returns promise or value of the latest version
fetchOptions | _object_ | isomorphic-fetch options (https://github.github.io/fetch/)
ignoreErrors | _boolean_ | true

- Result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export async function getLatestVersion(
} catch (e) {
if (option.ignoreErrors) {
console.warn(e); // eslint-disable-line no-console
return Promise.resolve('');
} else {
throw e;
}
Expand Down
7 changes: 7 additions & 0 deletions packages/react-native-version-check/src/needUpdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ export default async function needUpdate(
} catch (e) {
if (option.ignoreErrors) {
console.warn(e); // eslint-disable-line no-console

return Promise.resolve({
isNeeded: false,
storeUrl: providerStoreUrl,
currentVersion: option.currentVersion,
latestVersion: '',
});
} else {
throw e;
}
Expand Down