Prepare migration for sandboxing (path.join in preload)

This commit is contained in:
TC
2022-09-05 00:31:29 +02:00
parent 91e4433aba
commit 1f5f597561
4 changed files with 33 additions and 13 deletions

View File

@ -1,4 +1,3 @@
const path = require("path");
require("./providers/front-logger")();
const config = require("./config");
const { fileExists } = require("./plugins/utils");
@ -10,14 +9,26 @@ const plugins = config.plugins.getEnabled();
let api;
plugins.forEach(([plugin, options]) => {
const preloadPath = path.join(__dirname, "plugins", plugin, "preload.js");
plugins.forEach(async ([plugin, options]) => {
const preloadPath = await ipcRenderer.invoke(
"getPath",
__dirname,
"plugins",
plugin,
"preload.js"
);
fileExists(preloadPath, () => {
const run = require(preloadPath);
run(options);
});
const actionPath = path.join(__dirname, "plugins", plugin, "actions.js");
const actionPath = await ipcRenderer.invoke(
"getPath",
__dirname,
"plugins",
plugin,
"actions.js"
);
fileExists(actionPath, () => {
const actions = require(actionPath).actions || {};
@ -30,8 +41,14 @@ plugins.forEach(([plugin, options]) => {
});
document.addEventListener("DOMContentLoaded", () => {
plugins.forEach(([plugin, options]) => {
const pluginPath = path.join(__dirname, "plugins", plugin, "front.js");
plugins.forEach(async ([plugin, options]) => {
const pluginPath = await ipcRenderer.invoke(
"getPath",
__dirname,
"plugins",
plugin,
"front.js"
);
fileExists(pluginPath, () => {
const run = require(pluginPath);
run(options);