Prettier utils

This commit is contained in:
TC
2021-01-14 23:09:16 +01:00
parent ed09304ed7
commit d52dbee13c

View File

@ -4,15 +4,15 @@ const path = require("path");
const { ipcMain, ipcRenderer } = require("electron"); const { ipcMain, ipcRenderer } = require("electron");
// Creates a DOM element from a HTML string // Creates a DOM element from a HTML string
module.exports.ElementFromHtml = html => { module.exports.ElementFromHtml = (html) => {
var template = document.createElement("template"); var template = document.createElement("template");
html = html.trim(); // Never return a text node of whitespace as the result html = html.trim(); // Never return a text node of whitespace as the result
template.innerHTML = html; template.innerHTML = html;
return template.content.firstChild; return template.content.firstChild;
}; };
// Creates a DOM element from a HTML file // Creates a DOM element from a HTML file
module.exports.ElementFromFile = filepath => { module.exports.ElementFromFile = (filepath) => {
return module.exports.ElementFromHtml(fs.readFileSync(filepath, "utf8")); return module.exports.ElementFromHtml(fs.readFileSync(filepath, "utf8"));
}; };
@ -33,7 +33,7 @@ module.exports.listenAction = (channel, callback) => {
}; };
module.exports.fileExists = (path, callbackIfExists) => { module.exports.fileExists = (path, callbackIfExists) => {
fs.access(path, fs.F_OK, err => { fs.access(path, fs.F_OK, (err) => {
if (err) { if (err) {
return; return;
} }
@ -49,10 +49,10 @@ module.exports.injectCSS = (webContents, filepath) => {
}; };
module.exports.getAllPlugins = () => { module.exports.getAllPlugins = () => {
const isDirectory = source => fs.lstatSync(source).isDirectory(); const isDirectory = (source) => fs.lstatSync(source).isDirectory();
return fs return fs
.readdirSync(__dirname) .readdirSync(__dirname)
.map(name => path.join(__dirname, name)) .map((name) => path.join(__dirname, name))
.filter(isDirectory) .filter(isDirectory)
.map(name => path.basename(name)); .map((name) => path.basename(name));
}; };