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/webview/lib | |
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/webview/lib')
-rw-r--r-- | src/webview/lib/RecipeWebview.js | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/webview/lib/RecipeWebview.js b/src/webview/lib/RecipeWebview.js index 305e79882..96caa125e 100644 --- a/src/webview/lib/RecipeWebview.js +++ b/src/webview/lib/RecipeWebview.js | |||
@@ -1,5 +1,5 @@ | |||
1 | import { ipcRenderer } from 'electron'; | 1 | import { ipcRenderer } from 'electron'; |
2 | import { exists, pathExistsSync, readFile } from 'fs-extra'; | 2 | import { exists, pathExistsSync, readFileSync } from 'fs-extra'; |
3 | 3 | ||
4 | const debug = require('debug')('Ferdi:Plugin:RecipeWebview'); | 4 | const debug = require('debug')('Ferdi:Plugin:RecipeWebview'); |
5 | 5 | ||
@@ -55,9 +55,8 @@ class RecipeWebview { | |||
55 | injectCSS(...files) { | 55 | injectCSS(...files) { |
56 | files.forEach(async (file) => { | 56 | files.forEach(async (file) => { |
57 | if (pathExistsSync(file)) { | 57 | if (pathExistsSync(file)) { |
58 | const data = await readFile(file, 'utf8'); | ||
59 | const styles = document.createElement('style'); | 58 | const styles = document.createElement('style'); |
60 | styles.innerHTML = data; | 59 | styles.innerHTML = readFileSync(file, 'utf8'); |
61 | 60 | ||
62 | document.querySelector('head').appendChild(styles); | 61 | document.querySelector('head').appendChild(styles); |
63 | 62 | ||
@@ -69,8 +68,7 @@ class RecipeWebview { | |||
69 | injectJSUnsafe(...files) { | 68 | injectJSUnsafe(...files) { |
70 | Promise.all(files.map(async (file) => { | 69 | Promise.all(files.map(async (file) => { |
71 | if (await exists(file)) { | 70 | if (await exists(file)) { |
72 | const data = await readFile(file, 'utf8'); | 71 | return readFileSync(file, 'utf8'); |
73 | return data; | ||
74 | } | 72 | } |
75 | debug('Script not found', file); | 73 | debug('Script not found', file); |
76 | return null; | 74 | return null; |