@@ -61,18 +61,18 @@ export const loadPluginFromFile = async <T>(
6161/**
6262 * Load plugin from file or directory.
6363 *
64- * const plugin = await loadPlugin(process.cwd(), null, './renderer.js');
65- * const plugin = await loadPlugin('../node_modules', 'doxdox-renderer-', 'json');
64+ * const plugin = await loadPlugin([ process.cwd()] , null, './renderer.js');
65+ * const plugin = await loadPlugin([ '../node_modules'] , 'doxdox-renderer-', 'json');
6666 *
67- * @param {string } [directory ] Root directory to load plugin from.
67+ * @param {string[] } [directories ] Root directories to load plugin from.
6868 * @param {string } [prefix] Optional prefix to attach to the pathOrPackage.
6969 * @param {string } [pathOrPackage] Path or package name.
7070 * @return {Promise<T | null> } Plugin default method.
7171 * @public
7272 */
7373
7474export const loadPlugin = async < T > (
75- directory : string ,
75+ directories : string [ ] ,
7676 prefix : string | null ,
7777 pathOrPackage : string
7878) : Promise < T | null > => {
@@ -83,20 +83,17 @@ export const loadPlugin = async <T>(
8383 return await loadPluginFromFile ( pathOrPackage ) ;
8484 } else if ( await isDirectory ( pathOrPackage ) ) {
8585 return await loadPluginFromPackagePath ( pathOrPackage ) ;
86- } else if (
87- await isDirectory (
88- join (
89- directory ,
86+ } else {
87+ for ( let i = 0 ; i < directories ?. length ; i += 1 ) {
88+ const path = join (
89+ directories [ i ] ,
9090 `${ prefix } ${ pathOrPackage . replace ( prefixPattern , '' ) } `
91- )
92- )
93- ) {
94- return await loadPluginFromPackagePath (
95- join (
96- directory ,
97- `${ prefix } ${ pathOrPackage . replace ( prefixPattern , '' ) } `
98- )
99- ) ;
91+ ) ;
92+
93+ if ( await isDirectory ( path ) ) {
94+ return await loadPluginFromPackagePath ( path ) ;
95+ }
96+ }
10097 }
10198 } catch ( err ) {
10299 if ( process . env . DEBUG ) {
0 commit comments