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