diff options
author | 2021-08-08 00:01:37 +0000 | |
---|---|---|
committer | 2021-08-08 05:31:37 +0530 | |
commit | 97d51a7763b14c92ee71ff9a012311dd9498d803 (patch) | |
tree | bd36005031ecb1148f27aa541e7a92a5e3aa4c0c /src/webview/darkmode.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/webview/darkmode.js')
-rw-r--r-- | src/webview/darkmode.js | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/webview/darkmode.js b/src/webview/darkmode.js index ab629435c..7435d6404 100644 --- a/src/webview/darkmode.js +++ b/src/webview/darkmode.js | |||
@@ -1,7 +1,7 @@ | |||
1 | /* eslint no-bitwise: ["error", { "int32Hint": true }] */ | 1 | /* eslint no-bitwise: ["error", { "int32Hint": true }] */ |
2 | 2 | ||
3 | import path from 'path'; | 3 | import { join } from 'path'; |
4 | import fs from 'fs-extra'; | 4 | import { pathExistsSync, readFileSync } from 'fs-extra'; |
5 | 5 | ||
6 | const debug = require('debug')('Ferdi:DarkMode'); | 6 | const debug = require('debug')('Ferdi:DarkMode'); |
7 | 7 | ||
@@ -10,9 +10,9 @@ const chars = [...'abcdefghijklmnopqrstuvwxyz']; | |||
10 | const ID = [...Array(20)].map(() => chars[Math.random() * chars.length | 0]).join``; | 10 | const ID = [...Array(20)].map(() => chars[Math.random() * chars.length | 0]).join``; |
11 | 11 | ||
12 | export function injectDarkModeStyle(recipePath) { | 12 | export function injectDarkModeStyle(recipePath) { |
13 | const darkModeStyle = path.join(recipePath, 'darkmode.css'); | 13 | const darkModeStyle = join(recipePath, 'darkmode.css'); |
14 | if (fs.pathExistsSync(darkModeStyle)) { | 14 | if (pathExistsSync(darkModeStyle)) { |
15 | const data = fs.readFileSync(darkModeStyle); | 15 | const data = readFileSync(darkModeStyle); |
16 | const styles = document.createElement('style'); | 16 | const styles = document.createElement('style'); |
17 | styles.id = ID; | 17 | styles.id = ID; |
18 | styles.innerHTML = data.toString(); | 18 | styles.innerHTML = data.toString(); |