diff options
author | Vijay Raghavan Aravamudhan <vraravam@users.noreply.github.com> | 2021-08-08 00:01:37 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-08 05:31:37 +0530 |
commit | 97d51a7763b14c92ee71ff9a012311dd9498d803 (patch) | |
tree | bd36005031ecb1148f27aa541e7a92a5e3aa4c0c /src/index.js | |
parent | 5.6.1-nightly.17 [skip ci] (diff) | |
download | ferdium-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.js | 14 |
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 | ||
3 | import { app, BrowserWindow, shell, ipcMain, session } from 'electron'; | 3 | import { app, BrowserWindow, shell, ipcMain, session } from 'electron'; |
4 | 4 | ||
5 | import fs from 'fs-extra'; | 5 | import { emptyDirSync, ensureFileSync } from 'fs-extra'; |
6 | import path from 'path'; | 6 | import { join } from 'path'; |
7 | import windowStateKeeper from 'electron-window-state'; | 7 | import windowStateKeeper from 'electron-window-state'; |
8 | import { enforceMacOSAppLocation } from 'electron-util'; | 8 | import { enforceMacOSAppLocation } from 'electron-util'; |
9 | import ms from 'ms'; | 9 | import 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 | ||
24 | import { mainIpcHandler as basicAuthHandler } from './features/basicAuth'; | 26 | import { 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 |
66 | fs.emptyDirSync(path.join(app.getPath('userData'), 'recipes', 'temp')); | 68 | emptyDirSync(userDataRecipesPath('temp')); |
67 | fs.ensureFileSync(path.join(app.getPath('userData'), 'window-state.json')); | 69 | ensureFileSync(userDataPath('window-state.json')); |
68 | 70 | ||
69 | // Set App ID for Windows | 71 | // Set App ID for Windows |
70 | if (isWindows) { | 72 | if (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 | ), |