[MM-40406] Add more singletons, refactor main.ts into pieces, add tests and some cleanup + tests for additional coverage (#1890)
* Refactor main.ts dependencies into singleton pattern * Split main.ts into testable pieces, some other refactoring for singleton pattern * Unit tests for main/app/app * Unit tests for main/app/config * Unit tests for main/app/initialize * Unit tests for main/app/intercom * Unit tests for main/app/utils * Add some more tests to get to 70% coverage * Fix for linux * Fix for alternate data dir paths * Fix E2E test
This commit is contained in:
36
src/main/constants.ts
Normal file
36
src/main/constants.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
/* istanbul ignore file */
|
||||
|
||||
import path from 'path';
|
||||
|
||||
import {app, ipcMain} from 'electron';
|
||||
|
||||
import {UPDATE_PATHS} from 'common/communication';
|
||||
|
||||
let userDataPath;
|
||||
|
||||
export let configPath = '';
|
||||
export let allowedProtocolFile = '';
|
||||
export let appVersionJson = '';
|
||||
export let certificateStorePath = '';
|
||||
export let trustedOriginsStoreFile = '';
|
||||
export let boundsInfoPath = '';
|
||||
|
||||
export function updatePaths(emit = false) {
|
||||
userDataPath = app.getPath('userData');
|
||||
|
||||
configPath = `${userDataPath}/config.json`;
|
||||
allowedProtocolFile = path.resolve(userDataPath, 'allowedProtocols.json');
|
||||
appVersionJson = path.join(userDataPath, 'app-state.json');
|
||||
certificateStorePath = path.resolve(userDataPath, 'certificate.json');
|
||||
trustedOriginsStoreFile = path.resolve(userDataPath, 'trustedOrigins.json');
|
||||
boundsInfoPath = path.join(userDataPath, 'bounds-info.json');
|
||||
|
||||
if (emit) {
|
||||
ipcMain.emit(UPDATE_PATHS);
|
||||
}
|
||||
}
|
||||
|
||||
updatePaths();
|
Reference in New Issue
Block a user