From 97d51a7763b14c92ee71ff9a012311dd9498d803 Mon Sep 17 00:00:00 2001 From: Vijay Raghavan Aravamudhan Date: Sun, 8 Aug 2021 00:01:37 +0000 Subject: 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/ --- src/webview/lib/RecipeWebview.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/webview/lib') 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 @@ import { ipcRenderer } from 'electron'; -import { exists, pathExistsSync, readFile } from 'fs-extra'; +import { exists, pathExistsSync, readFileSync } from 'fs-extra'; const debug = require('debug')('Ferdi:Plugin:RecipeWebview'); @@ -55,9 +55,8 @@ class RecipeWebview { injectCSS(...files) { files.forEach(async (file) => { if (pathExistsSync(file)) { - const data = await readFile(file, 'utf8'); const styles = document.createElement('style'); - styles.innerHTML = data; + styles.innerHTML = readFileSync(file, 'utf8'); document.querySelector('head').appendChild(styles); @@ -69,8 +68,7 @@ class RecipeWebview { injectJSUnsafe(...files) { Promise.all(files.map(async (file) => { if (await exists(file)) { - const data = await readFile(file, 'utf8'); - return data; + return readFileSync(file, 'utf8'); } debug('Script not found', file); return null; -- cgit v1.2.3-70-g09d2