aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Amine <amine@mouafik.fr>2020-03-07 10:21:00 +0100
committerLibravatar GitHub <noreply@github.com>2020-03-07 10:21:00 +0100
commitaf64cbf216f9186c31a49d922add21b4e7356753 (patch)
tree86a9f373204e4b58d81378d1b6807aab5c21a70a
parentAdd support for unlocking with Touch ID (#423) (diff)
parentUse async methods of fs-extra (diff)
downloadferdium-app-af64cbf216f9186c31a49d922add21b4e7356753.tar.gz
ferdium-app-af64cbf216f9186c31a49d922add21b4e7356753.tar.zst
ferdium-app-af64cbf216f9186c31a49d922add21b4e7356753.zip
Merge pull request #436 from getferdi/fix/inject-css
Fix uncaught error on injectCSS that does not exist
-rw-r--r--src/webview/lib/RecipeWebview.js14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/webview/lib/RecipeWebview.js b/src/webview/lib/RecipeWebview.js
index 74d05fc2d..1d24326c5 100644
--- a/src/webview/lib/RecipeWebview.js
+++ b/src/webview/lib/RecipeWebview.js
@@ -67,14 +67,16 @@ class RecipeWebview {
67 * be an absolute path to the file 67 * be an absolute path to the file
68 */ 68 */
69 injectCSS(...files) { 69 injectCSS(...files) {
70 files.forEach((file) => { 70 files.forEach(async (file) => {
71 const data = fs.readFileSync(file); 71 if (await fs.exists(file)) {
72 const styles = document.createElement('style'); 72 const data = await fs.readFile(file);
73 styles.innerHTML = data.toString(); 73 const styles = document.createElement('style');
74 styles.innerHTML = data.toString();
74 75
75 document.querySelector('head').appendChild(styles); 76 document.querySelector('head').appendChild(styles);
76 77
77 debug('Append styles', styles); 78 debug('Append styles', styles);
79 }
78 }); 80 });
79 } 81 }
80 82