Skip to content

Commit

Permalink
Patch missing folder autogenerate for plugins (#2273)
Browse files Browse the repository at this point in the history
  • Loading branch information
timothycarambat authored Sep 12, 2024
1 parent de9f9a0 commit f5565dd
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions server/utils/agents/imported.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,23 @@ class ImportedPlugin {
return true;
}

/**
* Checks if the plugin folder exists and if it does not, creates the folder.
*/
static checkPluginFolderExists() {
const dir = path.resolve(pluginsPath);
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
return;
}

/**
* Loads plugins from `plugins` folder in storage that are custom loaded and defined.
* only loads plugins that are active: true.
* @returns {Promise<string[]>} - array of plugin names to be loaded later.
*/
static async activeImportedPlugins() {
const plugins = [];
this.checkPluginFolderExists();
const folders = fs.readdirSync(path.resolve(pluginsPath));
for (const folder of folders) {
const configLocation = path.resolve(
Expand All @@ -72,6 +82,7 @@ class ImportedPlugin {
*/
static listImportedPlugins() {
const plugins = [];
this.checkPluginFolderExists();
if (!fs.existsSync(pluginsPath)) return plugins;

const folders = fs.readdirSync(path.resolve(pluginsPath));
Expand Down

0 comments on commit f5565dd

Please sign in to comment.