Skip to content
Merged
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
3 changes: 2 additions & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
assertWeb,
emptyObj,
enhancedFetch,
info,
joinUrls,
log,
noop,
Expand Down Expand Up @@ -189,7 +190,7 @@
};
assertDebug = (matter: string) => {
if (__DEV__ && !this.options.debug) {
console.info(this.t('dev_debug_disabled', { matter }));
info(this.t('dev_debug_disabled', { matter }));
return false;
}
return true;
Expand Down Expand Up @@ -356,7 +357,7 @@
};
downloadUpdate = async (
info: CheckResult,
onDownloadProgress?: (data: ProgressData) => void,

Check warning on line 360 in src/client.ts

View workflow job for this annotation

GitHub Actions / lint (20.x)

'info' is already declared in the upper scope on line 25 column 3
) => {
const {
hash,
Expand Down
10 changes: 5 additions & 5 deletions src/core.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
import { emptyModule, log } from './utils';
import { emptyModule, error, log } from './utils';
import i18n from './i18n';
const {
version: v,
} = require('react-native/Libraries/Core/ReactNativeVersion');
Expand Down Expand Up @@ -46,10 +47,9 @@ if (currentVersionInfoString) {
delete _currentVersionInfo.debugChannel;
setLocalHashInfo(currentVersion, _currentVersionInfo);
}
} catch (error) {
console.error(
'Failed to parse currentVersionInfo:',
currentVersionInfoString,
} catch (err) {
error(
i18n.t('error_parse_version_info', { info: currentVersionInfoString }),
);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default {

// Error messages
error_appkey_required: 'appKey is required',
error_parse_version_info: 'Failed to parse currentVersionInfo: {{info}}',
error_update_check_failed: 'Update check failed',
error_cannot_connect_server:
'Can not connect to update server. Please check your network.',
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default {

// Error messages
error_appkey_required: '需要提供 appKey',
error_parse_version_info: '解析 currentVersionInfo 失败: {{info}}',
error_update_check_failed: '更新检查失败',
error_cannot_connect_server: '无法连接到更新服务器。请检查网络连接。',
error_cannot_connect_backup:
Expand Down
14 changes: 13 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ export function log(...args: any[]) {
console.log(i18n.t('dev_log_prefix'), ...args);
}

export function info(...args: any[]) {
console.info(i18n.t('dev_log_prefix'), ...args);
}

export function warn(...args: any[]) {
console.warn(i18n.t('dev_log_prefix'), ...args);
}

export function error(...args: any[]) {
console.error(i18n.t('dev_log_prefix'), ...args);
}

export const isWeb = Platform.OS === 'web';

export function promiseAny<T>(promises: Promise<T>[]) {
Expand Down Expand Up @@ -93,7 +105,7 @@ export const testUrls = async (urls?: string[]) => {

export const assertWeb = () => {
if (isWeb) {
console.warn(i18n.t('dev_web_not_supported'));
warn(i18n.t('dev_web_not_supported'));
return false;
}
return true;
Expand Down