SymphonyElectron/src/app/init.ts
Kiran Niranjan 873badf389
test: Spectron (Initial commit) (#838)
* Spectron - Initial commit

* Spectron - Only run unit tests on travis

* Spectron - Update npm script to copy config and refactor

* Spectron - Update readme

* Spectron - update test cases

* Spectron - Merge upstream Spectron

* Spectron - Update spectron to 10.0.0 and fix issues

* Spectron - rename travis file

* Spectron - install linux specific dependency

* Spectron - Fix indentation

* Spectron - Fix indentation

* Spectron - Remove unwanted script

* fix typo
2020-03-18 11:15:00 +05:30

41 lines
1.3 KiB
TypeScript

import { app } from 'electron';
import * as path from 'path';
import { isDevEnv, isNodeEnv } from '../common/env';
import { logger } from '../common/logger';
import { getCommandLineArgs } from '../common/utils';
import { appStats } from './stats';
// Handle custom user data path from process.argv
const userDataPathArg: string | null = getCommandLineArgs(process.argv, '--userDataPath=', false);
const userDataPath = userDataPathArg && userDataPathArg.substring(userDataPathArg.indexOf('=') + 1);
// force sandbox: true for all BrowserWindow instances.
if (!isNodeEnv) {
app.enableSandbox();
}
// need to set this explicitly if using Squirrel
// https://www.electron.build/configuration/configuration#Configuration-squirrelWindows
app.setAppUserModelId('com.symphony.electron-desktop');
// Set user data path before app ready event
if (isDevEnv) {
const devDataPath = path.join(app.getPath('appData'), 'Symphony-dev');
logger.info(`init: Setting user data path to`, devDataPath);
app.setPath('userData', devDataPath);
}
if (userDataPath) {
logger.info(`init: Setting user data path to`, userDataPath);
app.setPath('userData', userDataPath);
}
logger.info(`init: Fetch user data path`, app.getPath('userData'));
// Log app statistics
appStats.logStats();
// tslint:disable-next-line
require('./main');