Patch missing folder autogenerate for plugins (#2273)

This commit is contained in:
Timothy Carambat 2024-09-12 09:48:53 -07:00 committed by GitHub
parent de9f9a0ce8
commit f5565dd6c9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -45,6 +45,15 @@ class ImportedPlugin {
return true; 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. * Loads plugins from `plugins` folder in storage that are custom loaded and defined.
* only loads plugins that are active: true. * only loads plugins that are active: true.
@ -52,6 +61,7 @@ class ImportedPlugin {
*/ */
static async activeImportedPlugins() { static async activeImportedPlugins() {
const plugins = []; const plugins = [];
this.checkPluginFolderExists();
const folders = fs.readdirSync(path.resolve(pluginsPath)); const folders = fs.readdirSync(path.resolve(pluginsPath));
for (const folder of folders) { for (const folder of folders) {
const configLocation = path.resolve( const configLocation = path.resolve(
@ -72,6 +82,7 @@ class ImportedPlugin {
*/ */
static listImportedPlugins() { static listImportedPlugins() {
const plugins = []; const plugins = [];
this.checkPluginFolderExists();
if (!fs.existsSync(pluginsPath)) return plugins; if (!fs.existsSync(pluginsPath)) return plugins;
const folders = fs.readdirSync(path.resolve(pluginsPath)); const folders = fs.readdirSync(path.resolve(pluginsPath));