diff --git a/server/utils/agents/imported.js b/server/utils/agents/imported.js index 136f4a3ad..8a7da4802 100644 --- a/server/utils/agents/imported.js +++ b/server/utils/agents/imported.js @@ -45,6 +45,15 @@ 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. @@ -52,6 +61,7 @@ class ImportedPlugin { */ static async activeImportedPlugins() { const plugins = []; + this.checkPluginFolderExists(); const folders = fs.readdirSync(path.resolve(pluginsPath)); for (const folder of folders) { const configLocation = path.resolve( @@ -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));