mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-19 09:16:38 +00:00
Factorize duplicated configUrl code
Change-type: patch
This commit is contained in:
parent
ffe281f25d
commit
44fc429f64
@ -55,10 +55,7 @@ async function initConfig() {
|
||||
await installCorvus();
|
||||
let validatedConfig = null;
|
||||
try {
|
||||
const configUrl =
|
||||
(await settings.get('configUrl')) ||
|
||||
'https://balena.io/etcher/static/config.json';
|
||||
const config = await getConfig(configUrl);
|
||||
const config = await getConfig();
|
||||
const mixpanel = _.get(config, ['analytics', 'mixpanel'], {});
|
||||
mixpanelSample = mixpanel.probability || DEFAULT_PROBABILITY;
|
||||
if (isClientEligible(mixpanelSample)) {
|
||||
|
@ -114,10 +114,7 @@ async function createMainWindow() {
|
||||
});
|
||||
if (packageUpdatable) {
|
||||
try {
|
||||
const configUrl =
|
||||
(await settings.get('configUrl')) ||
|
||||
'https://balena.io/etcher/static/config.json';
|
||||
const onlineConfig = await getConfig(configUrl);
|
||||
const onlineConfig = await getConfig();
|
||||
const autoUpdaterConfig = _.get(
|
||||
onlineConfig,
|
||||
['autoUpdates', 'autoUpdaterConfig'],
|
||||
|
@ -21,6 +21,7 @@ import * as tmp from 'tmp';
|
||||
import { promisify } from 'util';
|
||||
|
||||
import * as errors from './errors';
|
||||
import * as settings from '../gui/app/models/settings';
|
||||
|
||||
const getAsync = promisify(request.get);
|
||||
|
||||
@ -50,7 +51,10 @@ export function hasProps(obj: any, props: string[]): boolean {
|
||||
* @summary Get etcher configs stored online
|
||||
* @param {String} - url where config.json is stored
|
||||
*/
|
||||
export async function getConfig(configUrl: string): Promise<any> {
|
||||
export async function getConfig(): Promise<_.Dictionary<any>> {
|
||||
const configUrl =
|
||||
(await settings.get('configUrl')) ||
|
||||
'https://balena.io/etcher/static/config.json';
|
||||
return (await getAsync({ url: configUrl, json: true })).body;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user