aboutsummaryrefslogtreecommitdiffstats
path: root/src/index.js
diff options
context:
space:
mode:
authorLibravatar Vijay Raghavan Aravamudhan <vraravam@users.noreply.github.com>2021-08-08 00:01:37 +0000
committerLibravatar GitHub <noreply@github.com>2021-08-08 05:31:37 +0530
commit97d51a7763b14c92ee71ff9a012311dd9498d803 (patch)
treebd36005031ecb1148f27aa541e7a92a5e3aa4c0c /src/index.js
parent5.6.1-nightly.17 [skip ci] (diff)
downloadferdium-app-97d51a7763b14c92ee71ff9a012311dd9498d803.tar.gz
ferdium-app-97d51a7763b14c92ee71ff9a012311dd9498d803.tar.zst
ferdium-app-97d51a7763b14c92ee71ff9a012311dd9498d803.zip
refactor: path-references refactoring and using 'import' instead of 'require' (#1752)
* refactor references to 'userData' and 'appData' directories to move hardcoding into single location * convert to es6 for lower memory usage as per https://codesource.io/the-difference-between-import-and-require-in-javascript/
Diffstat (limited to 'src/index.js')
-rw-r--r--src/index.js14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/index.js b/src/index.js
index 78ab9bef2..3264fdc63 100644
--- a/src/index.js
+++ b/src/index.js
@@ -2,8 +2,8 @@
2 2
3import { app, BrowserWindow, shell, ipcMain, session } from 'electron'; 3import { app, BrowserWindow, shell, ipcMain, session } from 'electron';
4 4
5import fs from 'fs-extra'; 5import { emptyDirSync, ensureFileSync } from 'fs-extra';
6import path from 'path'; 6import { join } from 'path';
7import windowStateKeeper from 'electron-window-state'; 7import windowStateKeeper from 'electron-window-state';
8import { enforceMacOSAppLocation } from 'electron-util'; 8import { enforceMacOSAppLocation } from 'electron-util';
9import ms from 'ms'; 9import ms from 'ms';
@@ -19,6 +19,8 @@ import {
19 isWindows, 19 isWindows,
20 isLinux, 20 isLinux,
21 aboutAppDetails, 21 aboutAppDetails,
22 userDataRecipesPath,
23 userDataPath,
22} from './environment'; 24} from './environment';
23 25
24import { mainIpcHandler as basicAuthHandler } from './features/basicAuth'; 26import { mainIpcHandler as basicAuthHandler } from './features/basicAuth';
@@ -63,8 +65,8 @@ function onDidLoad(fn) {
63} 65}
64 66
65// Ensure that the recipe directory exists 67// Ensure that the recipe directory exists
66fs.emptyDirSync(path.join(app.getPath('userData'), 'recipes', 'temp')); 68emptyDirSync(userDataRecipesPath('temp'));
67fs.ensureFileSync(path.join(app.getPath('userData'), 'window-state.json')); 69ensureFileSync(userDataPath('window-state.json'));
68 70
69// Set App ID for Windows 71// Set App ID for Windows
70if (isWindows) { 72if (isWindows) {
@@ -193,7 +195,7 @@ const createWindow = () => {
193 nodeIntegration: true, 195 nodeIntegration: true,
194 contextIsolation: false, 196 contextIsolation: false,
195 webviewTag: true, 197 webviewTag: true,
196 preload: path.join(__dirname, 'sentry.js'), 198 preload: join(__dirname, 'sentry.js'),
197 enableRemoteModule: true, 199 enableRemoteModule: true,
198 }, 200 },
199 }); 201 });
@@ -401,7 +403,7 @@ app.on('ready', () => {
401 program: process.execPath, 403 program: process.execPath,
402 arguments: `${isDevMode ? `${__dirname} ` : ''}--reset-window`, 404 arguments: `${isDevMode ? `${__dirname} ` : ''}--reset-window`,
403 iconPath: asarPath( 405 iconPath: asarPath(
404 path.join( 406 join(
405 isDevMode ? `${__dirname}../src/` : __dirname, 407 isDevMode ? `${__dirname}../src/` : __dirname,
406 'assets/images/taskbar/win32/display.ico', 408 'assets/images/taskbar/win32/display.ico',
407 ), 409 ),