Skip to content

Commit

Permalink
feat: jsdocs for loaders
Browse files Browse the repository at this point in the history
  • Loading branch information
xhyrom committed Apr 30, 2022
1 parent e85e3d8 commit bb0391b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lib/loaders/directoryLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import * as fs from 'fs';
import * as path from 'path';
import { Util } from '../util/Util';

export async function directoryLoader(dir: string): Promise<Array<any>> {
/**
* The method that loads all files from a directory
* @param {string} dir The directory to load
* @returns {Promise<any[]>}
*/
export async function directoryLoader(dir: string): Promise<any[]> {
let files = [];
if (fs.existsSync(dir)) {
for await (const fsDirent of fs.readdirSync(dir, { withFileTypes: true })) {
Expand Down
9 changes: 9 additions & 0 deletions src/lib/loaders/pluginFinder.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import * as fs from 'node:fs';
import * as path from 'node:path';

/**
* The method that loads plugin files from a directory
* @param basedir The base plugin directory
* @param folder The plugin folder
*/
export async function loadPluginFolder(basedir: string, folder: fs.Dirent) {
if (folder.isDirectory()) {
if (fs.existsSync(path.join(basedir, folder.name, 'index.js'))) {
Expand All @@ -19,6 +24,10 @@ export async function loadPluginFolder(basedir: string, folder: fs.Dirent) {
}
}

/**
* The method that find all plugins in a directory
* @param {string} basedir The directory to find plugins in
*/
export async function pluginFinder(basedir: string) {
if (fs.existsSync(basedir)) {
if (fs.existsSync(path.join(basedir, 'plugins'))) {
Expand Down

0 comments on commit bb0391b

Please sign in to comment.